[][src]Struct sequoia_store::Binding

pub struct Binding { /* fields omitted */ }

Represents an entry in a Mapping.

Mappings map labels to Certs. A Binding represents a pair in this relation. We make this explicit because we associate metadata with these pairs.

Implementations

impl Binding[src]

pub fn stats(&self) -> Result<Stats>[src]

Returns stats for this binding.

Examples

let mapping = Mapping::open(&ctx, net::Policy::Offline,
                            REALM_CONTACTS, "default")?;

let fp = Fingerprint::from_bytes(b"bbbbbbbbbbbbbbbbbbbb");
let binding = mapping.add("Mister B.", &fp)?;

println!("Binding {:?}", binding.stats()?);
// prints:
// Binding Stats {
//     created: Some(Timespec { tv_sec: 1513704042, tv_nsec: 0 }),
//     updated: None,
//     encryption: Stamps { count: 0, first: None, last: None },
//     verification: Stamps { count: 0, first: None, last: None }
// }

pub fn key(&self) -> Result<Key>[src]

Returns the Key of this binding.

pub fn cert(&self) -> Result<Cert>[src]

Returns the Cert of this binding.

A shortcut for self.key()?.cert().

pub fn import(&self, cert: &Cert) -> Result<Cert>[src]

Updates this binding with the given Cert.

If the new key cert matches the current key, i.e. they have the same fingerprint, both keys are merged and normalized. The returned key contains all packets known to Sequoia, and should be used instead of cert.

If the new key does not match the current key, and it does not carry a valid signature from the current key, an Error::Conflict is returned, and you have to resolve the conflict, either by ignoring the new key, or by using Binding::rotate to force a rotation.

Examples

let mapping = Mapping::open(&ctx, net::Policy::Offline,
                            REALM_CONTACTS, "default")?;
mapping.import("Testy McTestface", &old)?;
// later...
let binding = mapping.lookup("Testy McTestface")?;
let r = binding.import(&new);
assert!(r.is_err()); // Conflict!

pub fn rotate(&self, cert: &Cert) -> Result<Cert>[src]

Forces a keyrotation to the given Cert.

The current key is replaced with the new key cert, even if they do not have the same fingerprint. If a key with the same fingerprint as cert is already in the store, is merged with cert and normalized. The returned key contains all packets known to Sequoia, and should be used instead of cert.

Use this function to resolve conflicts returned from Binding::import. Make sure that you have authenticated cert properly. How to do that depends on your thread model. You could simply ask Alice to call her communication partner Bob and confirm that he rotated his keys.

Examples

let mapping = Mapping::open(&ctx, net::Policy::Offline,
                            REALM_CONTACTS, "default")?;
mapping.import("Testy McTestface", &old)?;
// later...
let binding = mapping.lookup("Testy McTestface")?;
let r = binding.import(&new);
assert!(r.is_err()); // Conflict!
let r = binding.rotate(&new)?;
assert_eq!(new.fingerprint(), r.fingerprint());

pub fn delete(self) -> Result<()>[src]

Deletes this binding.

Examples

let mapping = Mapping::open(&ctx, net::Policy::Offline,
                            REALM_CONTACTS, "default")?;
let fp = Fingerprint::from_bytes(b"bbbbbbbbbbbbbbbbbbbb");
let binding = mapping.add("Mister B.", &fp)?;
binding.delete()?;
let binding = mapping.lookup("Mister B.");
assert!(binding.is_err()); // not found

pub fn log(&self) -> Result<LogIter>[src]

Lists all log entries related to this binding.

pub fn label(&self) -> Result<String>[src]

Gets this binding's label.

Trait Implementations

impl Debug for Binding[src]

Auto Trait Implementations

impl !RefUnwindSafe for Binding

impl !Send for Binding

impl !Sync for Binding

impl Unpin for Binding

impl !UnwindSafe for Binding

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,