Struct mtbl::Writer
[−]
[src]
pub struct Writer { pub options: WriterOptions, // some fields omitted }
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);Run
Fields
options: WriterOptions
The options used to create this MTBL file.
Methods
impl Writer
[src]
fn create_from_path<T: AsRef<Path>>(path: T) -> IOResult<Writer>
Create an empty MTBL file at the given path.
fn create_from_file<T: 'static + AsRawFd>(file: T) -> IOResult<Writer>
Create an empty MTBL file from the given File
.
fn as_raw_ptr(&mut self) -> *mut mtbl_writer
Get the underlying mtbl_writer pointer.
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
impl Write for Writer
[src]
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.