[−][src]Struct exonum_merkledb::indexes::ProofEntry
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]
T: RawAccess,
V: BinaryValue,
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]
T: RawAccessMut,
V: BinaryValue + ObjectHash,
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]
T: Access,
V: BinaryValue + ObjectHash,
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]
impl<T, V> ObjectHash for ProofEntry<T, V> where
T: RawAccess,
V: BinaryValue + ObjectHash,
[src]
T: RawAccess,
V: BinaryValue + ObjectHash,
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());
fn object_hash(&self) -> Hash
[src]
Auto Trait Implementations
impl<T, V> RefUnwindSafe for ProofEntry<T, V> where
T: RefUnwindSafe,
V: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
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,
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,
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,
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,
T: UnwindSafe,
V: UnwindSafe,
<T as RawAccess>::Changes: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,