Trait LogWriterExt

Source
pub trait LogWriterExt: LogWriter {
    // Provided methods
    fn insert_generic<T>(
        &self,
        value: &T,
    ) -> Result<ValuePointer<Self::Id>, Either<T::Error, Error>>
       where T: Type,
             Self::Id: CheapClone + Debug { ... }
    fn insert_with<E>(
        &self,
        vb: ValueBuilder<impl FnOnce(&mut VacantBuffer<'_>) -> Result<(), E>>,
    ) -> Result<ValuePointer<Self::Id>, Either<E, Error>>
       where Self::Id: CheapClone + Debug { ... }
    fn insert_generic_tombstone<T>(
        &self,
        value: &T,
    ) -> Result<ValuePointer<Self::Id>, Either<T::Error, Error>>
       where T: Type,
             Self::Id: CheapClone + Debug { ... }
    fn insert_tombstone_with<E>(
        &self,
        vb: ValueBuilder<impl FnOnce(&mut VacantBuffer<'_>) -> Result<(), E>>,
    ) -> Result<ValuePointer<Self::Id>, Either<E, Error>>
       where Self::Id: CheapClone + Debug { ... }
}
Expand description

The extension trait for the LogWriter trait.

The reason having a LogWriterExt is that to make LogWriter object-safe.

Provided Methods§

Source

fn insert_generic<T>( &self, value: &T, ) -> Result<ValuePointer<Self::Id>, Either<T::Error, Error>>
where T: Type, Self::Id: CheapClone + Debug,

Inserts a generic value into the log.

§Example
use valog::{Builder, sync::ValueLog, LogWriterExt};

let log = Builder::new().with_capacity(1024).alloc::<ValueLog>(0).unwrap();
let vp = log.insert_generic(&"Hello, valog!".to_string()).unwrap();
Source

fn insert_with<E>( &self, vb: ValueBuilder<impl FnOnce(&mut VacantBuffer<'_>) -> Result<(), E>>, ) -> Result<ValuePointer<Self::Id>, Either<E, Error>>
where Self::Id: CheapClone + Debug,

Inserts a value into the log with a builder, the value is built in place.

§Example
use valog::{Builder, sync::ValueLog, LogWriterExt, ValueBuilder, VacantBuffer};

let log = Builder::new().with_capacity(1024).alloc::<ValueLog>(0).unwrap();
let data = b"Hello, valog!";
let vb = ValueBuilder::new(data.len(), |buf: &mut VacantBuffer<'_>| {
  buf.put_slice(data)
});
let vp = log.insert_with(vb).unwrap();
Source

fn insert_generic_tombstone<T>( &self, value: &T, ) -> Result<ValuePointer<Self::Id>, Either<T::Error, Error>>
where T: Type, Self::Id: CheapClone + Debug,

Inserts a generic value into the log.

This method is almost the same as the insert_generic method, the only difference is that this method will increases the discarded bytes of the log.

§Example
use valog::{Builder, sync::ValueLog, LogWriterExt};

let log = Builder::new().with_capacity(1024).alloc::<ValueLog>(0).unwrap();
let vp = log.insert_generic_tombstone(&"Hello, valog!".to_string()).unwrap();
Source

fn insert_tombstone_with<E>( &self, vb: ValueBuilder<impl FnOnce(&mut VacantBuffer<'_>) -> Result<(), E>>, ) -> Result<ValuePointer<Self::Id>, Either<E, Error>>
where Self::Id: CheapClone + Debug,

Inserts a value into the log with a builder, the value is built in place.

This method is almost the same as the insert_with method, the only difference is that this method will increases the discarded bytes of the log.

§Example
use valog::{Builder, sync::ValueLog, LogWriterExt, ValueBuilder, VacantBuffer};

let log = Builder::new().with_capacity(1024).alloc::<ValueLog>(0).unwrap();
let data = b"Hello, valog!";
let vb = ValueBuilder::new(data.len(), |buf: &mut VacantBuffer<'_>| {
  buf.put_slice(data)
});
let vp = log.insert_tombstone_with(vb).unwrap();

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.

Implementors§

Source§

impl<L> LogWriterExt for L
where L: LogWriter,