Struct gnudbm::Entry [] [src]

pub struct Entry<'a> { /* fields omitted */ }

An entry in a gdbm database.

This type represents arbitrary data retrieved from the database.

Methods

impl<'a> Entry<'a>
[src]

[src]

Returns the contents of the entry as a slice of bytes.

This is zero-cost; the returned slice is the memory returned by the gdbm C library.

Examples

let key = "my key";
let value = "my value";
db.store(key.as_bytes(), &value).unwrap();

let entry = db.fetch(key.as_bytes()).unwrap();

assert_eq!(entry.as_bytes(), value.as_bytes());

[src]

Attempts to deserialize this entry into some type which implements [serde::Serialize].

This can borrow data, bound to the lifetime of self.

Examples

let key = "my key";

// BTreeMap implements `Serialize` so we can insert it and parse from an entry.
let value = [("hi", 5), ("you", 2), ("eye", 1)].iter()
    .cloned()
    .collect::<BTreeMap<&'static str, i32>>();
db.store(key.as_bytes(), &value).unwrap();

let entry = db.fetch(key.as_bytes()).unwrap();
let as_map: BTreeMap<&str, i32> = entry.deserialize().unwrap();

assert_eq!(as_map.get("hi"), Some(&5));

Trait Implementations

impl<'a> Debug for Entry<'a>
[src]

[src]

Formats the value using the given formatter.