mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-27 03:43:36 +04:00
20 lines
421 B
Rust
20 lines
421 B
Rust
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}; |