pub struct WriteBuffer { /* private fields */ }Expand description
Manages in-progress file writes, mapping file handles to their buffers.
Implementations§
Source§impl WriteBuffer
impl WriteBuffer
Sourcepub fn new(spool_dir: PathBuf) -> Self
pub fn new(spool_dir: PathBuf) -> Self
spool_dir is where every buffer’s backing file lives; resolve it with
crate::spool::spool_dir_from_env and prepare it before calling this.
Sourcepub fn open(
&mut self,
fh: u64,
inode: u64,
original_size: u64,
) -> Result<&mut FileBuffer>
pub fn open( &mut self, fh: u64, inode: u64, original_size: u64, ) -> Result<&mut FileBuffer>
Register a new write buffer for the given file handle.
Sourcepub fn write(
&mut self,
fh: u64,
offset: i64,
data: &[u8],
) -> Result<u32, MountError>
pub fn write( &mut self, fh: u64, offset: i64, data: &[u8], ) -> Result<u32, MountError>
Write data at offset into the buffer for fh.
Sourcepub fn read(
&mut self,
fh: u64,
offset: i64,
size: u32,
) -> Result<Vec<u8>, MountError>
pub fn read( &mut self, fh: u64, offset: i64, size: u32, ) -> Result<Vec<u8>, MountError>
Read data from the buffer for fh.
Sourcepub fn flush(&mut self, fh: u64) -> Option<FileBuffer>
pub fn flush(&mut self, fh: u64) -> Option<FileBuffer>
Remove and return the buffer for flushing to MTP.
Sourcepub fn close(&mut self, fh: u64) -> Option<FileBuffer>
pub fn close(&mut self, fh: u64) -> Option<FileBuffer>
Alias for flush – used at file close time.
pub fn is_open(&self, fh: u64) -> bool
Auto Trait Implementations§
impl Freeze for WriteBuffer
impl RefUnwindSafe for WriteBuffer
impl Send for WriteBuffer
impl Sync for WriteBuffer
impl Unpin for WriteBuffer
impl UnsafeUnpin for WriteBuffer
impl UnwindSafe for WriteBuffer
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