Skip to main content

WriteBuffer

Struct WriteBuffer 

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

Manages in-progress file writes, mapping file handles to their buffers.

Implementations§

Source§

impl WriteBuffer

Source

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.

Source

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.

Source

pub fn write( &mut self, fh: u64, offset: i64, data: &[u8], ) -> Result<u32, MountError>

Write data at offset into the buffer for fh.

Source

pub fn read( &mut self, fh: u64, offset: i64, size: u32, ) -> Result<Vec<u8>, MountError>

Read data from the buffer for fh.

Source

pub fn flush(&mut self, fh: u64) -> Option<FileBuffer>

Remove and return the buffer for flushing to MTP.

Source

pub fn close(&mut self, fh: u64) -> Option<FileBuffer>

Alias for flush – used at file close time.

Source

pub fn is_open(&self, fh: u64) -> bool

Source

pub fn size(&self, fh: u64) -> Option<u64>

Current buffered size for the given file handle.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.