Enum iota_stronghold::types::Location
source · pub enum Location {
Generic {
vault_path: Vec<u8>,
record_path: Vec<u8>,
},
Counter {
vault_path: Vec<u8>,
counter: usize,
},
}
Expand description
A Location
type used to specify where in the Stronghold
a piece of data should be stored. A generic location
specifies a non-versioned location while a counter location specifies a versioned location. The Counter location can
be used to get the head of the version chain by passing in None
as the counter index. Otherwise, counter records
are referenced through their associated index. On Read, the None
location is the latest record in the version
chain while on Write, the None
location is the next record in the version chain.
Note: For each used vault an encryption key is created and protected through the libsodium memory protection API. Many systems place limits on the amount of memory that may be locked by a process, which may result in the system panicking if the upper bound is reached! For users that write a large number of secrets into Stronghold, we strongly advise against writing each record in a separate vault, but instead group them into a limited number of different vaults.
Variants§
Implementations§
source§impl Location
impl Location
sourcepub fn vault_path(&self) -> &[u8] ⓘ
pub fn vault_path(&self) -> &[u8] ⓘ
Gets the vault_path from the Location.
sourcepub fn record_path(&self) -> &[u8] ⓘ
pub fn record_path(&self) -> &[u8] ⓘ
Returns the record_path
from the Location
. If the Location
type is Self::Counter
,
the vault_path
will be returned.
sourcepub fn generic<V: Into<Vec<u8>>, R: Into<Vec<u8>>>(
vault_path: V,
record_path: R
) -> Self
pub fn generic<V: Into<Vec<u8>>, R: Into<Vec<u8>>>( vault_path: V, record_path: R ) -> Self
Creates a generic location from types that implement Into<Vec<u8>>
.
sourcepub fn counter<V: Into<Vec<u8>>, C: Into<usize>>(
vault_path: V,
counter: C
) -> Self
pub fn counter<V: Into<Vec<u8>>, C: Into<usize>>( vault_path: V, counter: C ) -> Self
Creates a counter location from a type that implements Into<Vec<u8>>
and a counter type that implements
Into<usize>
sourcepub const fn const_generic(vault_path: Vec<u8>, record_path: Vec<u8>) -> Self
pub const fn const_generic(vault_path: Vec<u8>, record_path: Vec<u8>) -> Self
Used to generate a constant generic location.
sourcepub const fn const_counter(vault_path: Vec<u8>, counter: usize) -> Self
pub const fn const_counter(vault_path: Vec<u8>, counter: usize) -> Self
used to generate a constant counter location.