pub struct PathRef<'a> { /* private fields */ }Expand description
A path that borrows its joined form instead of owning one.
What an engine has in hand when it reads a key out of its own page: the
bytes are there, in the joined spelling a path keeps, and
building a StorePath per key would allocate once for every entry on the
hot path of loading a map.
It carries the same checked-ness as an owned path and can be had no other
way: either PathRef::parse walked the key, or it borrows a path that
was walked already. So a caller holding one needs no opinion about how a
path is spelled, which is the whole point - the alternative is passing
&str and hoping every reader remembers what it is.
Implementations§
Source§impl<'a> PathRef<'a>
impl<'a> PathRef<'a>
Sourcepub fn parse(joined: &'a str) -> Result<Self, StorePathError>
pub fn parse(joined: &'a str) -> Result<Self, StorePathError>
Reads a key an engine holds, refusing one this library did not write.
The same walk StorePath::parse_joined makes, without the
allocation that follows it.
pub fn is_root(&self) -> bool
Sourcepub fn level_under(&self, prefix: &StorePath) -> Under<'a>
pub fn level_under(&self, prefix: &StorePath) -> Under<'a>
Where this sits under prefix, and the level it sits at. See
StorePath::level_under, which answers the same question of an owned
path.
Sourcepub fn name_under(&self, prefix: &StorePath) -> Option<Level<'a>>
pub fn name_under(&self, prefix: &StorePath) -> Option<Level<'a>>
The level directly under prefix, or None when prefix does not
hold this path. See StorePath::name_under.
Trait Implementations§
impl<'a> Copy for PathRef<'a>
impl<'a> Eq for PathRef<'a>
Source§impl<'a> From<&'a StorePath> for PathRef<'a>
Borrowing a path costs nothing and checks nothing: it has been through the
check already.
impl<'a> From<&'a StorePath> for PathRef<'a>
Borrowing a path costs nothing and checks nothing: it has been through the check already.