[−][src]Struct sonnerie::create_tx::CreateTx
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]
&mut self,
key: &str,
format: &str,
data: &[u8]
) -> Result<(), WriteFailure>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,