-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for running wasi:cli components
- Loading branch information
Showing
16 changed files
with
671 additions
and
618 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use anyhow::Error; | ||
use async_trait::async_trait; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use wasmtime_wasi::{HostOutputStream, StdoutStream, StreamError, StreamResult, Subscribe}; | ||
|
||
pub struct LogStream { | ||
pub output: File, | ||
} | ||
|
||
impl StdoutStream for LogStream { | ||
fn stream(&self) -> Box<dyn HostOutputStream> { | ||
Box::new(LogStream { | ||
output: self.output.try_clone().expect(""), | ||
}) | ||
} | ||
|
||
fn isatty(&self) -> bool { | ||
false | ||
} | ||
} | ||
|
||
impl HostOutputStream for LogStream { | ||
fn write(&mut self, bytes: bytes::Bytes) -> StreamResult<()> { | ||
self.output | ||
.write_all(bytes.as_ref()) | ||
.map_err(|e| StreamError::LastOperationFailed(Error::from(e))) | ||
} | ||
|
||
fn flush(&mut self) -> StreamResult<()> { | ||
self.output | ||
.flush() | ||
.map_err(|e| StreamError::LastOperationFailed(Error::from(e))) | ||
} | ||
|
||
fn check_write(&mut self) -> StreamResult<usize> { | ||
Ok(1024 * 1024) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Subscribe for LogStream { | ||
async fn ready(&mut self) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.