mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-27 15:41:33 +00:00
make file like implement the std::io traits instead and wrap zbox file
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
use crate::vfs::file_like::{FileLike, Metadata};
|
||||
use failure::Error;
|
||||
use std::io;
|
||||
use std::io::{Seek, Write};
|
||||
|
||||
pub struct Stdin;
|
||||
pub struct Stdout;
|
||||
@ -12,19 +11,27 @@ impl FileLike for Stdin {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn write_file(&mut self, _buf: &[u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn read_file(&mut self, _buf: &mut [u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
||||
panic!("Cannot set length of stdin");
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Read for Stdin {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Write for Stdin {
|
||||
fn write(&mut self, _buf: &[u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> Result<(), io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Seek for Stdin {
|
||||
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
|
||||
unimplemented!()
|
||||
@ -36,18 +43,28 @@ impl FileLike for Stdout {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn write_file(&mut self, buf: &[u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
||||
panic!("Cannot set length of stdout");
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Read for Stdout {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Write for Stdout {
|
||||
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
|
||||
let stdout = io::stdout();
|
||||
let mut handle = stdout.lock();
|
||||
handle.write(buf)
|
||||
}
|
||||
|
||||
fn read_file(&mut self, _buf: &mut [u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
||||
panic!("Cannot set length of stdout");
|
||||
fn flush(&mut self) -> Result<(), io::Error> {
|
||||
let stdout = io::stdout();
|
||||
let mut handle = stdout.lock();
|
||||
handle.flush()
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,18 +79,28 @@ impl FileLike for Stderr {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn write_file(&mut self, buf: &[u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
||||
panic!("Cannot set length of stderr");
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Read for Stderr {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Write for Stderr {
|
||||
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
|
||||
let stderr = io::stderr();
|
||||
let mut handle = stderr.lock();
|
||||
handle.write(buf)
|
||||
}
|
||||
|
||||
fn read_file(&mut self, _buf: &mut [u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
||||
panic!("Cannot set length of stderr");
|
||||
fn flush(&mut self) -> Result<(), io::Error> {
|
||||
let stderr = io::stderr();
|
||||
let mut handle = stderr.lock();
|
||||
handle.flush()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user