pub struct Key(/* private fields */);Implementations§
Source§impl Key
impl Key
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
A key as a store hands it back.
Takes the bytes as they are; Key::path is where a key that this type
did not write is refused, because that is where the answer has somewhere
to go.
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn is_root(&self) -> bool
Sourcepub fn path(&self) -> Result<StorePath, StorePathError>
pub fn path(&self) -> Result<StorePath, StorePathError>
The path this key spells.
Refuses what this type does not write: bytes that are not text, a level left unterminated, and an escape that escapes nothing. Reading any of those leniently would let two keys name one path.
Sourcepub fn under(&self, prefix: &Key) -> bool
pub fn under(&self, prefix: &Key) -> bool
Whether this key names prefix or something under it.
One test, because a level’s terminator cannot occur inside a level: a
key under pot starts with pot\0, potato does not, and there is no
third answer for a caller to filter afterwards.
Sourcepub fn subtree(&self) -> (&[u8], Option<KeyBytes>)
pub fn subtree(&self) -> (&[u8], Option<KeyBytes>)
The half-open range this key’s subtree occupies, both ends exact. The root has no top.
The top is this key with its last byte raised, which reaches everything under it because that byte is a terminator - the lowest there is, so raising it lands past every level the key could hold and short of its next sibling.