pub struct Handle(pub u64);Expand description
Opaque file handle for POSIX-style I/O operations.
Represents an open file descriptor. Used with FsHandles
for handle-based read/write operations, and with FsLock
for file locking.
§Lifecycle
- Open: Call
FsHandles::opento get a handle - Use: Call
read_at,write_at,lock, etc. - Close: Call
FsHandles::closeto release
§Example
use anyfs_backend::{FsHandles, OpenFlags, Handle};
use std::path::Path;
// Generic function that works with any FsHandles implementation
fn write_with_handle<B: FsHandles>(fs: &B) -> Result<(), anyfs_backend::FsError> {
// Open file for writing
let handle: Handle = fs.open(Path::new("/data.bin"), OpenFlags::WRITE)?;
// Write at specific offset
fs.write_at(handle, b"Hello", 0)?;
fs.write_at(handle, b"World", 5)?;
// Always close the handle
fs.close(handle)?;
Ok(())
}§Internal Value
The u64 value is backend-defined. It could be an inode number, array index,
or any other unique identifier. Treat it as opaque.
Tuple Fields§
§0: u64Trait Implementations§
impl Copy for Handle
impl Eq for Handle
impl StructuralPartialEq for Handle
Auto Trait Implementations§
impl Freeze for Handle
impl RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnwindSafe for Handle
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