Trait axfs::api::port::FileIO

source ·
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§

source

fn readable(&self) -> bool

whether the file is readable

source

fn writable(&self) -> bool

whether the file is writable

source

fn executable(&self) -> bool

whether the file is executable

source

fn get_type(&self) -> FileIOType

获取类型

Provided Methods§

source

fn read(&self, _buf: &mut [u8]) -> AxResult<usize>

读取操作

source

fn write(&self, _buf: &[u8]) -> AxResult<usize>

写入操作

source

fn flush(&self) -> AxResult<()>

刷新操作

source

fn seek(&self, _pos: SeekFrom) -> AxResult<u64>

移动指针操作

source

fn get_path(&self) -> String

获取路径

source

fn get_stat(&self) -> AxResult<Kstat>

获取文件信息

source

fn truncate(&self, _len: usize) -> AxResult<()>

截断文件到指定长度

source

fn print_content(&self)

debug

source

fn set_status(&self, _flags: OpenFlags) -> bool

设置文件状态

source

fn get_status(&self) -> OpenFlags

获取文件状态

source

fn set_close_on_exec(&self, _is_set: bool) -> bool

设置 close_on_exec 位 设置成功返回false

source

fn in_exceptional_conditions(&self) -> bool

处于“意外情况”。在 (p)select 和 (p)poll 中会使用到

当前基本默认为false

source

fn is_hang_up(&self) -> bool

是否已经终止,对pipe来说相当于另一端已经关闭

对于其他文件类型来说,是在被close的时候终止,但这个时候已经没有对应的filedesc了,所以自然不会调用这个函数

source

fn ready_to_read(&self) -> bool

已准备好读。对于 pipe 来说,这意味着读端的buffer内有值

source

fn ready_to_write(&self) -> bool

已准备好写。对于 pipe 来说,这意味着写端的buffer未满

source

fn ioctl(&self, _request: usize, _arg1: usize) -> AxResult<()>

To control the file descriptor

Implementors§