[][src]Struct sonnerie::create_tx::CreateTx

pub struct CreateTx { /* fields omitted */ }

Create a transaction file in the specified db directory.

Add new records with [new_record]. They must be in sorted order.

After adding records, call [commit] which ensures the transaction is on disk. Not calling commit will rollback the transaction.

Methods

impl CreateTx[src]

pub fn new(dir: &Path) -> Result<CreateTx>[src]

Open a transaction file inside this specific directory.

The transaction is named "tx.XXX.tmp" where XXX is an increasing value basedo on timestamp.

On commit, the file is renamed to not have the ".tmp" suffix.

pub fn add_record(
    &mut self,
    key: &str,
    format: &str,
    data: &[u8]
) -> Result<(), WriteFailure>
[src]

Add a record with the given key, format, and payload.

The data must match the format (otherwise you can corrupt the database). The data also encodes the timestamp.

Each successive call to this function must have greater or equal values for key and timestamp.

Encode the data with [row_format].

pub fn commit_to(self, final_name: &Path) -> Result<()>[src]

Commit the transaction, but give it a specific name.

This function is necessary for compacting, normally you would just call the basic [commit].

pub fn commit(self) -> Result<()>[src]

Commit the transaction.

On successful completion, the data is on disk (fsync is called) and the filename is renamed to lose its ".tmp" suffix.

Trait Implementations

impl Drop for CreateTx[src]

Auto Trait Implementations

impl !RefUnwindSafe for CreateTx

impl Send for CreateTx

impl Sync for CreateTx

impl Unpin for CreateTx

impl !UnwindSafe for CreateTx

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,