Struct galvanize::writer::Writer [] [src]

pub struct Writer<'a, F: Write + Read + Seek + 'a> { /* fields omitted */ }

Allows you to create a (or append to) CDB.

Example

use galvanize::Writer;
use std::fs::File;

let mut f = try!(File::create(filename));
let mut cdb_writer = try!(Writer::new(&mut f));
let key = "key".as_bytes();
let value = "value".as_bytes();
try!(cdb_writer.put(key, value));

// Write out the hash table from the `Writer` and transform into a `Reader`
let mut cdb_reader = try!(cdb_writer.as_reader());
let stored_vals = cdb_reader.get(key);
assert_eq!(stored_vals.len(), 1);
assert_eq!(&stored_vals[0][..], &value[..]);  // "value".as_bytes()

Methods

impl<'a, F: Write + Read + Seek + 'a> Writer<'a, F>
[src]

Creates a new Reader consuming the provided file.

The file must allow writes to be performed.

Used by Reader::as_writer method, to prepopulate the index from the underlying file.

Write value for key into this CDB.

Transform this Writer into a Reader using the same underlying file.

The Writer will flush the hash table to the underlying file.

Trait Implementations

impl<'a, F: Write + Read + Seek + 'a> Drop for Writer<'a, F>
[src]

Write out the hash table footer for this CDB.