pub struct ReadWriteFileHandle { /* private fields */ }
Expand description
A read-write file handle that allows shared access to the file.
This struct provides a platform-independent way to open a file in read-write mode while allowing other processes to access the file simultaneously.
Note: ReadWriteFileHandle
is Send
but not Sync
. It should only be
accessed from a single thread.
Implementations§
Source§impl ReadWriteFileHandle
impl ReadWriteFileHandle
Sourcepub fn create_preallocated<P: AsRef<Path>>(
path: P,
size: i64,
) -> Result<Self, HandleOpenError>
pub fn create_preallocated<P: AsRef<Path>>( path: P, size: i64, ) -> Result<Self, HandleOpenError>
Creates a new file with pre-allocated size.
This creates a new file and pre-allocates the specified amount of space. If the file already exists, it will be truncated and pre-allocated to the specified size.
§Arguments
path
- The path where the file should be createdsize
- The size to pre-allocate in bytes
§Errors
Returns a HandleOpenError
if:
- The file cannot be created
- Pre-allocation fails
- The path is invalid
Sourcepub fn handle(&self) -> &InnerHandle
pub fn handle(&self) -> &InnerHandle
Returns a reference to the underlying file descriptor or handle.
This can be used for further operations if needed.
Sourcepub fn size(&self) -> Result<i64, HandleOpenError>
pub fn size(&self) -> Result<i64, HandleOpenError>
Returns the size of the file in bytes.
Trait Implementations§
impl Send for ReadWriteFileHandle
Auto Trait Implementations§
impl Freeze for ReadWriteFileHandle
impl RefUnwindSafe for ReadWriteFileHandle
impl Sync for ReadWriteFileHandle
impl Unpin for ReadWriteFileHandle
impl UnwindSafe for ReadWriteFileHandle
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