pub trait FileIO: AsAny + Send + Sync {
Show 20 methods
// Required methods
fn readable(&self) -> bool;
fn writable(&self) -> bool;
fn executable(&self) -> bool;
fn get_type(&self) -> FileIOType;
// Provided methods
fn read(&self, _buf: &mut [u8]) -> AxResult<usize> { ... }
fn write(&self, _buf: &[u8]) -> AxResult<usize> { ... }
fn flush(&self) -> AxResult<()> { ... }
fn seek(&self, _pos: SeekFrom) -> AxResult<u64> { ... }
fn get_path(&self) -> String { ... }
fn get_stat(&self) -> AxResult<Kstat> { ... }
fn truncate(&self, _len: usize) -> AxResult<()> { ... }
fn print_content(&self) { ... }
fn set_status(&self, _flags: OpenFlags) -> bool { ... }
fn get_status(&self) -> OpenFlags { ... }
fn set_close_on_exec(&self, _is_set: bool) -> bool { ... }
fn in_exceptional_conditions(&self) -> bool { ... }
fn is_hang_up(&self) -> bool { ... }
fn ready_to_read(&self) -> bool { ... }
fn ready_to_write(&self) -> bool { ... }
fn ioctl(&self, _request: usize, _arg1: usize) -> AxResult<()> { ... }
}
Expand description
File I/O trait. 文件I/O操作,用于设置文件描述符,值得注意的是,这里的read/write/seek都是不可变引用
因为文件描述符读取的时候,是用到内部File成员的读取函数,自身应当为不可变,从而可以被Arc指针调用
Required Methods§
sourcefn executable(&self) -> bool
fn executable(&self) -> bool
whether the file is executable
sourcefn get_type(&self) -> FileIOType
fn get_type(&self) -> FileIOType
获取类型
Provided Methods§
sourcefn print_content(&self)
fn print_content(&self)
debug
sourcefn set_status(&self, _flags: OpenFlags) -> bool
fn set_status(&self, _flags: OpenFlags) -> bool
设置文件状态
sourcefn get_status(&self) -> OpenFlags
fn get_status(&self) -> OpenFlags
获取文件状态
sourcefn set_close_on_exec(&self, _is_set: bool) -> bool
fn set_close_on_exec(&self, _is_set: bool) -> bool
设置 close_on_exec 位 设置成功返回false
sourcefn in_exceptional_conditions(&self) -> bool
fn in_exceptional_conditions(&self) -> bool
处于“意外情况”。在 (p)select 和 (p)poll 中会使用到
当前基本默认为false
sourcefn is_hang_up(&self) -> bool
fn is_hang_up(&self) -> bool
是否已经终止,对pipe来说相当于另一端已经关闭
对于其他文件类型来说,是在被close的时候终止,但这个时候已经没有对应的filedesc了,所以自然不会调用这个函数
sourcefn ready_to_read(&self) -> bool
fn ready_to_read(&self) -> bool
已准备好读。对于 pipe 来说,这意味着读端的buffer内有值
sourcefn ready_to_write(&self) -> bool
fn ready_to_write(&self) -> bool
已准备好写。对于 pipe 来说,这意味着写端的buffer未满