[−][src]Struct exonum_merkledb::IndexAddress
Represents the address of an index in the database.
An address has a string name and an optional byte key. An index is uniquely identified
by its address. Different addresses correspond to different indexes. Addresses with the same
name and differing keys are said to belong to the same group (see also Group
). Groups
can be used for a potentially unbounded group of indexes that can be identified by a certain
key (for example, ProofListIndex
with the transaction history of a wallet keyed by the
PublicKey
of the wallet).
In contrast with ResolvedAddress
, IndexAddress
is a high-level logical construct;
it does not directly map to key-value storage abstractions (column families and their keys).
Examples
IndexAddress
can be used implicitly, since &str
and (&str, &impl BinaryKey)
can both
be converted into an address.
use exonum_merkledb::{access::CopyAccessExt, IndexAddress, TemporaryDB, Database}; let db = TemporaryDB::new(); let fork = db.fork(); // Using a string address: let map = fork.get_map::<_, String, u8>("map"); // Using an address within an index family: let list = fork.get_list::<_, String>(("index", &3_u32)); // Using `IndexAddress` explicitly: let addr = IndexAddress::from_root("data").append_key(&vec![1, 2, 3]); let set = fork.get_value_set::<_, u64>(addr);
Methods
impl IndexAddress
[src]
pub fn from_root<S: Into<String>>(root: S) -> Self
[src]
Creates new IndexAddress
with the specified name.
pub fn name(&self) -> &str
[src]
Returns the name part of IndexAddress
.
pub fn id_in_group(&self) -> Option<&[u8]>
[src]
Returns the bytes part of IndexAddress
.
pub fn prepend_name(self, prefix: &str) -> Self
[src]
Prepends a name part to IndexAddress
. The name is separated from the existing name
by a dot .
.
Examples
let addr = IndexAddress::from_root("foo"); let prefixed = addr.prepend_name("prefix"); assert_eq!(prefixed.name(), "prefix.foo");
pub fn append_name(self, suffix: &str) -> Self
[src]
Appends a name part to IndexAddress
. The name is separated from the existing name
by a dot .
.
Examples
let addr = IndexAddress::from_root("foo"); let suffixed = addr.append_name("suffix"); assert_eq!(suffixed.name(), "foo.suffix");
pub fn append_key<K: BinaryKey + ?Sized>(self, suffix: &K) -> Self
[src]
Appends a key to the IndexAddress
.
Trait Implementations
impl Clone for IndexAddress
[src]
fn clone(&self) -> IndexAddress
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for IndexAddress
[src]
impl Default for IndexAddress
[src]
fn default() -> IndexAddress
[src]
impl Eq for IndexAddress
[src]
impl<'_> From<&'_ str> for IndexAddress
[src]
impl<'a, K: BinaryKey + ?Sized> From<(&'a str, &'a K)> for IndexAddress
[src]
impl From<String> for IndexAddress
[src]
impl Hash for IndexAddress
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<IndexAddress> for IndexAddress
[src]
fn eq(&self, other: &IndexAddress) -> bool
[src]
fn ne(&self, other: &IndexAddress) -> bool
[src]
impl StructuralEq for IndexAddress
[src]
impl StructuralPartialEq for IndexAddress
[src]
Auto Trait Implementations
impl RefUnwindSafe for IndexAddress
impl Send for IndexAddress
impl Sync for IndexAddress
impl Unpin for IndexAddress
impl UnwindSafe for IndexAddress
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,