Writer

Struct Writer 

Source
pub struct Writer {
    pub options: WriterOptions,
    /* private fields */
}
Expand description

A struct to create an MTBL file from keys and values in sorted order.

Note that keys must be added in sorted order (by key), since they are written to disk. To create an MTBL providing keys in non-sorted order, use a Sorter.

To create a Writer with non-default options, see WriterOptions.

§Examples

let mut writer = Writer::create_from_path("/tmp/f.mtbl");
writer.add("a", dat_a);
writer.add("b", dat_b);

Fields§

§options: WriterOptions

The options used to create this MTBL file.

Implementations§

Source§

impl Writer

Source

pub fn create_from_path<T: AsRef<Path>>(path: T) -> IOResult<Writer>

Create an empty MTBL file at the given path.

Source

pub fn create_from_file<T: 'static + AsRawFd>(file: T) -> IOResult<Writer>

Create an empty MTBL file from the given File.

Source

pub fn as_raw_ptr(&mut self) -> *mut mtbl_writer

Get the underlying mtbl_writer pointer.

Source

pub fn add_all_sorted<T, U, I>(&mut self, iterable: I) -> Result<(), ()>
where T: AsRef<[u8]>, U: AsRef<[u8]>, I: IntoIterator<Item = (T, U)>,

Add all elements from a sorted iterator.

If the inputs are not all sorted (and after all the elements already added to the Writer), the result will be an Err, and that element and all further elements will not be written to the MTBL file.

Trait Implementations§

Source§

impl Drop for Writer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Write for Writer

Source§

fn add<T, U>(&mut self, key: T, value: U) -> Result<(), ()>
where T: AsRef<[u8]>, U: AsRef<[u8]>,

Add a key-value pair to be written to the MTBL file.

Keys must be provided in sorted order. If keys are not provided in sorted order, this will result in an Err.

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl !RefUnwindSafe for Writer

§

impl !Send for Writer

§

impl !Sync for Writer

§

impl Unpin for Writer

§

impl !UnwindSafe for Writer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.