pub struct OpenFile { /* private fields */ }Expand description
An open file handle.
Implementations§
Source§impl OpenFile
impl OpenFile
Sourcepub fn new(
scheme: DynScheme,
file_id: u64,
path: String,
open_flags: OpenFlags,
file_flags: FileFlags,
size: Option<u64>,
) -> Self
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.
Sourcepub fn read(&self, buf: &mut [u8]) -> Result<usize, SyscallError>
pub fn read(&self, buf: &mut [u8]) -> Result<usize, SyscallError>
Read from the file at current offset, advancing the offset.
Sourcepub fn write(&self, buf: &[u8]) -> Result<usize, SyscallError>
pub fn write(&self, buf: &[u8]) -> Result<usize, SyscallError>
Write to the file at current offset, advancing the offset.
Sourcepub fn pread(&self, offset: u64, buf: &mut [u8]) -> Result<usize, SyscallError>
pub fn pread(&self, offset: u64, buf: &mut [u8]) -> Result<usize, SyscallError>
Read at a specific offset without changing current offset (pread).
Sourcepub fn pwrite(&self, offset: u64, buf: &[u8]) -> Result<usize, SyscallError>
pub fn pwrite(&self, offset: u64, buf: &[u8]) -> Result<usize, SyscallError>
Write at a specific offset without changing current offset (pwrite).
Sourcepub fn seek(&self, new_offset: u64) -> Result<u64, SyscallError>
pub fn seek(&self, new_offset: u64) -> Result<u64, SyscallError>
Seek to a new offset (absolute).
Sourcepub fn lseek(&self, off: i64, whence: u32) -> Result<u64, SyscallError>
pub fn lseek(&self, off: i64, whence: u32) -> Result<u64, SyscallError>
POSIX lseek: whence=0 SET, 1 CUR, 2 END.
Sourcepub fn size(&self) -> Result<u64, SyscallError>
pub fn size(&self) -> Result<u64, SyscallError>
Get file size.
Sourcepub fn sync(&self) -> Result<(), SyscallError>
pub fn sync(&self) -> Result<(), SyscallError>
Sync file to storage.
Sourcepub fn close(&self) -> Result<(), SyscallError>
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
Sourcepub fn open_flags(&self) -> OpenFlags
pub fn open_flags(&self) -> OpenFlags
Get open flags.
Sourcepub fn stat(&self) -> Result<FileStat, SyscallError>
pub fn stat(&self) -> Result<FileStat, SyscallError>
Get file metadata.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OpenFile
impl !RefUnwindSafe for OpenFile
impl Send for OpenFile
impl Sync for OpenFile
impl Unpin for OpenFile
impl UnsafeUnpin for OpenFile
impl !UnwindSafe for OpenFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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