[−][src]Struct exonum_merkledb::indexes::Entry
An 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
trait.
Methods
impl<T, V> Entry<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_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_entry("name"); assert!(!index.exists()); index.set(10); assert!(index.exists());
impl<T, V> Entry<T, V> where
T: RawAccessMut,
V: BinaryValue,
[src]
T: RawAccessMut,
V: BinaryValue,
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_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_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_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_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 Entry<T, V>
[src]
impl<T, V> FromAccess<T> for Entry<T::Base, V> where
T: Access,
V: BinaryValue,
[src]
T: Access,
V: BinaryValue,
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]
Auto Trait Implementations
impl<T, V> RefUnwindSafe for Entry<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 Entry<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 Entry<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 Entry<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 Entry<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>,