pub struct FileBuffer {
pub inode: u64,
pub original_size: u64,
/* private fields */
}Expand description
Per-file write buffer backed by an unlinked temp file in the spool dir.
Fields§
§inode: u64§original_size: u64Implementations§
Source§impl FileBuffer
impl FileBuffer
Sourcepub fn new(inode: u64, original_size: u64, spool_dir: &Path) -> Result<Self>
pub fn new(inode: u64, original_size: u64, spool_dir: &Path) -> Result<Self>
Creates the backing temp file in spool_dir. The whole file being
written buffers here before upload, so spool_dir must be disk-backed
(see crate::spool).
Sourcepub fn write_at(&mut self, offset: i64, data: &[u8]) -> Result<u32>
pub fn write_at(&mut self, offset: i64, data: &[u8]) -> Result<u32>
Write data at offset, growing the file and zero-filling gaps as needed.
Returns the number of bytes written.
Sourcepub fn read_at(&mut self, offset: i64, size: u32) -> Result<Vec<u8>>
pub fn read_at(&mut self, offset: i64, size: u32) -> Result<Vec<u8>>
Read up to size bytes starting at offset. Returns fewer bytes if
the offset is near or past the end.
pub fn len(&self) -> u64
pub fn is_empty(&self) -> bool
pub fn is_dirty(&self) -> bool
Auto Trait Implementations§
impl Freeze for FileBuffer
impl RefUnwindSafe for FileBuffer
impl Send for FileBuffer
impl Sync for FileBuffer
impl Unpin for FileBuffer
impl UnsafeUnpin for FileBuffer
impl UnwindSafe for FileBuffer
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