Storage

Trait Storage 

Source
pub trait Storage<T>
where Self: Sized,
{ // Required methods fn buffer_mut(&mut self) -> &mut Vec<T>; fn flush(&mut self) -> Result<(), Box<dyn Error>>; // Provided methods fn add(&mut self, item: T) -> Result<(), Box<dyn Error>> { ... } fn finish(self) -> Result<(), Box<dyn Error>> { ... } }

Required Methods§

Source

fn buffer_mut(&mut self) -> &mut Vec<T>

Returns a mutable reference to the internal buffer

Source

fn flush(&mut self) -> Result<(), Box<dyn Error>>

Flush the buffer to disk

Provided Methods§

Source

fn add(&mut self, item: T) -> Result<(), Box<dyn Error>>

Add an item to the buffer, Default implemetation calls Storage::flush if it reaches capacity

Source

fn finish(self) -> Result<(), Box<dyn Error>>

Flush the buffer and consume self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> Storage<T> for Vec<T>

Source§

fn buffer_mut(&mut self) -> &mut Vec<T>

Source§

fn add(&mut self, item: T) -> Result<(), Box<dyn Error>>

Source§

fn flush(&mut self) -> Result<(), Box<dyn Error>>

Implementors§