mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-30 09:01:33 +00:00
refactor everything
This commit is contained in:
@ -1,25 +1,60 @@
|
||||
use crate::vfs::file_like::{FileLike, Metadata};
|
||||
use failure::Error;
|
||||
use std::io;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
pub struct Stdin;
|
||||
pub struct Stdout;
|
||||
pub struct Stderr;
|
||||
|
||||
impl FileLike for Stdin {
|
||||
fn write(&mut self, _buf: &[u8], count: usize, _offset: usize) -> Result<usize, Error> {
|
||||
println!("writing to {} byte to dev stream...", count);
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn close(&self) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn metadata(&self) -> Result<Metadata, Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn write_file(&mut self, _buf: &[u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for Stdin {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl FileLike for Stdout {
|
||||
fn metadata(&self) -> Result<Metadata, failure::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn write_file(&mut self, buf: &[u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
let stdout = io::stdout();
|
||||
let mut handle = stdout.lock();
|
||||
handle.write(buf)
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for Stdout {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl FileLike for Stderr {
|
||||
fn metadata(&self) -> Result<Metadata, failure::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn write_file(&mut self, buf: &[u8], _offset: usize) -> Result<usize, io::Error> {
|
||||
let stderr = io::stderr();
|
||||
let mut handle = stderr.lock();
|
||||
handle.write(buf)
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for Stderr {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user