pub struct Key {
pub namespace: String,
pub set_name: String,
pub user_key: Option<Value>,
pub digest: [u8; 20],
}Expand description
Unique record identifier.
Records can be identified using a specified namespace, an optional set name and a user defined key which must be unique within a set. Records can also be identified by namespace/digest, which is the combination used on the server.
Fields§
§namespace: StringNamespace.
set_name: StringSet name.
user_key: Option<Value>Original user key.
digest: [u8; 20]Unique server hash value generated from set name and user key.
Implementations§
Source§impl Key
impl Key
Sourcepub fn new<S>(namespace: S, set_name: S, key: Value) -> Result<Key, Error>
pub fn new<S>(namespace: S, set_name: S, key: Value) -> Result<Key, Error>
Construct a new key given a namespace, a set name and a user key value.
§Panics
Only integers, strings and blobs (Vec<u8>) can be used as user keys. The constructor will
panic if any other value type is passed.
Sourcepub fn key_with_digest<S>(
namespace: String,
set_name: Option<String>,
key: Option<Value>,
digest: [u8; 20],
) -> Result<Key, Error>
pub fn key_with_digest<S>( namespace: String, set_name: Option<String>, key: Option<Value>, digest: [u8; 20], ) -> Result<Key, Error>
Construct a new key from namespace, optional set name, user key and digest. The server handles record identifiers by digest only. The digest will be set to the provided value and not validated.
Sourcepub fn partition_id(&self) -> usize
pub fn partition_id(&self) -> usize
Returns the partitionId of the key.
§Panics
Panics if the digest slice cannot be read as a u32 in little-endian byte order.