pub enum AdaptiveBuffer {
Memory(Vec<u8>),
File(LargeBuffer),
}Expand description
Adaptive buffer that switches between in-memory and file-backed storage.
Variants§
Memory(Vec<u8>)
In-memory buffer for small data.
File(LargeBuffer)
File-backed buffer for large data.
Implementations§
Source§impl AdaptiveBuffer
impl AdaptiveBuffer
Sourcepub const fn with_threshold(_threshold: usize) -> Self
pub const fn with_threshold(_threshold: usize) -> Self
Create a new adaptive buffer with a custom threshold.
Sourcepub fn append(&mut self, data: &[u8], threshold: usize) -> Result<()>
pub fn append(&mut self, data: &[u8], threshold: usize) -> Result<()>
Append data to the buffer.
§Errors
Returns an error if file operations fail when using file-backed storage.
Sourcepub const fn is_file_backed(&self) -> bool
pub const fn is_file_backed(&self) -> bool
Check if the buffer is using file-backed storage.
Sourcepub fn as_str_lossy(&mut self) -> Result<String>
pub fn as_str_lossy(&mut self) -> Result<String>
Trait Implementations§
Source§impl Debug for AdaptiveBuffer
impl Debug for AdaptiveBuffer
Auto Trait Implementations§
impl Freeze for AdaptiveBuffer
impl RefUnwindSafe for AdaptiveBuffer
impl Send for AdaptiveBuffer
impl Sync for AdaptiveBuffer
impl Unpin for AdaptiveBuffer
impl UnwindSafe for AdaptiveBuffer
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