[][src]Struct exonum_merkledb::IndexAddress

pub struct IndexAddress { /* fields omitted */ }

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]

impl Debug for IndexAddress[src]

impl Default for 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]

impl PartialEq<IndexAddress> for IndexAddress[src]

impl StructuralEq for IndexAddress[src]

impl StructuralPartialEq for IndexAddress[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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