[][src]Struct exonum_merkledb::indexes::ProofEntry

pub struct ProofEntry<T: RawAccess, V> { /* fields omitted */ }

A hashed index that may only contain one element.

You can add an element to this index and check whether it exists. A value should implement BinaryValue and ObjectHash traits. Unlike Entry, hashed entries are eagerly hashed and may participate in state aggregation.

Methods

impl<T, V> ProofEntry<T, V> where
    T: RawAccess,
    V: BinaryValue
[src]

pub fn get(&self) -> Option<V>[src]

Returns a value of the entry or None if does not exist.

Examples

use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, Entry};

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");
assert_eq!(None, index.get());

index.set(10);
assert_eq!(Some(10), index.get());

pub fn exists(&self) -> bool[src]

Returns true if a value of the entry exists.

Examples

use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, Entry};

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");
assert!(!index.exists());

index.set(10);
assert!(index.exists());

impl<T, V> ProofEntry<T, V> where
    T: RawAccessMut,
    V: BinaryValue + ObjectHash
[src]

pub fn set(&mut self, value: V)[src]

Changes a value of the entry.

Examples

use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, Entry};

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");

index.set(10);
assert_eq!(Some(10), index.get());

pub fn remove(&mut self)[src]

Removes a value of the entry.

Examples

use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, Entry};

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");

index.set(10);
assert_eq!(Some(10), index.get());

index.remove();
assert_eq!(None, index.get());

pub fn take(&mut self) -> Option<V>[src]

Takes the value out of the entry, leaving a None in its place.

Examples

use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, Entry};

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");

index.set(10);
assert_eq!(Some(10), index.get());

let value = index.take();
assert_eq!(Some(10), value);
assert_eq!(None, index.get());

pub fn swap(&mut self, value: V) -> Option<V>[src]

Replaces the value in the entry with the given one, returning the previously stored value.

Examples

use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, Entry};

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");

index.set(10);
assert_eq!(Some(10), index.get());

let value = index.swap(20);
assert_eq!(Some(10), value);
assert_eq!(Some(20), index.get());

Trait Implementations

impl<T: Debug + RawAccess, V: Debug> Debug for ProofEntry<T, V>[src]

impl<T, V> FromAccess<T> for ProofEntry<T::Base, V> where
    T: Access,
    V: BinaryValue + ObjectHash
[src]

impl<T, V> ObjectHash for ProofEntry<T, V> where
    T: RawAccess,
    V: BinaryValue + ObjectHash
[src]

object_hash is computed as SHA-256 of the entry serialization, or Hash::zero() if the entry is not set.

Examples

let db = TemporaryDB::new();
let fork = db.fork();
let mut index = fork.get_proof_entry("name");
assert_eq!(Hash::default(), index.object_hash());

let value = 10;
index.set(value);
assert_eq!(exonum_crypto::hash(&[value]), index.object_hash());

Auto Trait Implementations

impl<T, V> RefUnwindSafe for ProofEntry<T, V> where
    T: RefUnwindSafe,
    V: RefUnwindSafe,
    <T as RawAccess>::Changes: RefUnwindSafe

impl<T, V> Send for ProofEntry<T, V> where
    T: Send,
    V: Send,
    <T as RawAccess>::Changes: Send

impl<T, V> Sync for ProofEntry<T, V> where
    T: Sync,
    V: Sync,
    <T as RawAccess>::Changes: Sync

impl<T, V> Unpin for ProofEntry<T, V> where
    T: Unpin,
    V: Unpin,
    <T as RawAccess>::Changes: Unpin

impl<T, V> UnwindSafe for ProofEntry<T, V> where
    T: UnwindSafe,
    V: UnwindSafe,
    <T as RawAccess>::Changes: UnwindSafe

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, U> Into<U> for T where
    U: From<T>, 
[src]

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>,