Skip to main content

OpenFile

Struct OpenFile 

Source
pub struct OpenFile { /* private fields */ }
Expand description

An open file handle.

Implementations§

Source§

impl OpenFile

Source

pub fn new( scheme: DynScheme, file_id: u64, path: String, open_flags: OpenFlags, file_flags: FileFlags, size: Option<u64>, ) -> Self

Create a new open file.

Source

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

Read from the file at current offset, advancing the offset.

Source

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

Write to the file at current offset, advancing the offset.

Source

pub fn pread(&self, offset: u64, buf: &mut [u8]) -> Result<usize, SyscallError>

Read at a specific offset without changing current offset (pread).

Source

pub fn pwrite(&self, offset: u64, buf: &[u8]) -> Result<usize, SyscallError>

Write at a specific offset without changing current offset (pwrite).

Source

pub fn seek(&self, new_offset: u64) -> Result<u64, SyscallError>

Seek to a new offset (absolute).

Source

pub fn lseek(&self, off: i64, whence: u32) -> Result<u64, SyscallError>

POSIX lseek: whence=0 SET, 1 CUR, 2 END.

Source

pub fn tell(&self) -> u64

Get current offset.

Source

pub fn size(&self) -> Result<u64, SyscallError>

Get file size.

Source

pub fn sync(&self) -> Result<(), SyscallError>

Sync file to storage.

Source

pub fn close(&self) -> Result<(), SyscallError>

Signal that this file descriptor is being closed.

Does NOT call scheme.close() directly; the actual scheme close is deferred to the Drop impl so it fires only when the last Arc is released (POSIX: scheme is closed when all dup’d/fork’d copies are gone).

Source

pub fn flags(&self) -> FileFlags

Get file flags.

Source

pub fn open_flags(&self) -> OpenFlags

Get open flags.

Source

pub fn path(&self) -> &str

Get path (for debugging).

Source

pub fn stat(&self) -> Result<FileStat, SyscallError>

Get file metadata.

Source

pub fn readdir(&self) -> Result<Vec<DirEntry>, SyscallError>

List directory entries (only valid for directories).

Source

pub fn file_id(&self) -> u64

Get internal file_id (for scheme delegation).

Source

pub fn scheme(&self) -> &DynScheme

Get the underlying scheme.

Trait Implementations§

Source§

impl Drop for OpenFile

Source§

fn drop(&mut self)

Performs the drop operation.

Auto Trait Implementations§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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>,

Source§

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.