Struct axfs::fops::File

source ·
pub struct File { /* private fields */ }
Expand description

An opened file object, with open permissions and a cursor.

Implementations§

source§

impl File

source

pub fn open(path: &str, opts: &OpenOptions) -> AxResult<Self>

Opens a file at the path relative to the current directory. Returns a File object.

source

pub fn truncate(&self, size: u64) -> AxResult

Truncates the file to the specified size.

source

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

Reads the file at the current position. Returns the number of bytes read.

After the read, the cursor will be advanced by the number of bytes read.

source

pub fn read_at(&self, offset: u64, buf: &mut [u8]) -> AxResult<usize>

Reads the file at the given position. Returns the number of bytes read.

It does not update the file cursor.

source

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

Writes the file at the current position. Returns the number of bytes written.

After the write, the cursor will be advanced by the number of bytes written.

source

pub fn write_at(&self, offset: u64, buf: &[u8]) -> AxResult<usize>

Writes the file at the given position. Returns the number of bytes written.

It does not update the file cursor.

source

pub fn flush(&self) -> AxResult

Flushes the file, writes all buffered data to the underlying device.

source

pub fn seek(&mut self, pos: SeekFrom) -> AxResult<u64>

Sets the cursor of the file to the specified offset. Returns the new position after the seek.

source

pub fn get_attr(&self) -> AxResult<FileAttr>

Gets the file attributes.

source

pub fn readable(&self) -> bool

whether the file is readable.

source

pub fn writable(&self) -> bool

whether the file is writable.

source

pub fn executable(&self) -> bool

whether the file is executable.

Trait Implementations§

source§

impl Clone for File

source§

fn clone(&self) -> File

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Drop for File

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl !UnwindSafe for File

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

把当前对象转化为 Any 类型,供后续 downcast 使用
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

供 downcast_mut 使用
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.