Trait os::fs::File

source · []
pub trait File: Send + Sync {
    fn readable(&self) -> bool;
fn writable(&self) -> bool;
fn read(&self, buf: UserBuffer) -> usize;
fn write(&self, buf: UserBuffer) -> usize; fn kread(&self, _offset: Option<&mut usize>, _buffer: &mut [u8]) -> usize { ... }
fn kwrite(&self, _offset: Option<&mut usize>, _buffer: &[u8]) -> usize { ... }
fn ioctl(&self, _cmd: u32, _arg: usize) -> isize { ... }
fn r_ready(&self) -> bool { ... }
fn w_ready(&self) -> bool { ... }
fn hang_up(&self) -> bool { ... }
fn stat(&self) -> Box<Stat> { ... } }
Expand description

File trait for regular and special files.

Required methods

Whether the file is inherently readable. Usually used as an indicator for authority for regular files.

Whether the file is inherently writable. Usually used as an indicator for authority for regular files.

Provided methods

Read a buffer from the file into the kernel buffer.

Unimplementation (Mis)Information

This function must be manually implemented. Calling the default implementation will result in a todo!() panic.

Write to a buffer from the file into the kernel buffer.

Unimplementation (Mis)Information

This function must be manually implemented. Calling the default implementation will result in a todo!() panic.

Control the device file. manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g., terminals) may be controlled with ioctl() requests. See the specific file type and its implementation for hint about available commands and arguments.

Check whether the current file is ready to be read.

Unimplementation (Mis)Information

If the function is left unimplemented, it will always return true.

Check whether the current file is ready to be written to

Unimplementation (Mis)Information

If the function is left unimplemented, it will always return true.

Check whether the current file is hanged up and has nothing to read. In pipes, this functions checks whether the counterpart has closed the other end.

Unimplementation (Mis)Information

If the function is left unimplemented, it will always return false.

Get the Stat for this file.

Implementors