Rewrite Stdin/Stdout
This commit is contained in:
parent
e5bd98973d
commit
e93a4a0b76
8 changed files with 338 additions and 42 deletions
20
os/src/fs/mod.rs
Normal file
20
os/src/fs/mod.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
mod pipe;
|
||||
mod stdio;
|
||||
|
||||
use crate::mm::UserBuffer;
|
||||
use core::any::Any;
|
||||
|
||||
pub trait File : Any + Send + Sync {
|
||||
fn read(&self, buf: UserBuffer) -> usize;
|
||||
fn write(&self, buf: UserBuffer) -> usize;
|
||||
fn as_any_ref(&self) -> &dyn Any;
|
||||
}
|
||||
|
||||
impl dyn File {
|
||||
pub fn downcast_ref<T: File>(&self) -> Option<&T> {
|
||||
self.as_any_ref().downcast_ref::<T>()
|
||||
}
|
||||
}
|
||||
|
||||
pub use pipe::{Pipe};
|
||||
pub use stdio::{Stdin, Stdout};
|
Loading…
Add table
Add a link
Reference in a new issue