pub struct Facet(/* private fields */);
Expand description
A Facet represent a point in a given hierarchy.
They are typically represented similarly to a filepath.
For instance, an e-commerce website could
have a Facet
for /electronics/tv_and_video/led_tv
.
A document can be associated with any number of facets.
The hierarchy implicitly imply that a document
belonging to a facet also belongs to the ancestor of
its facet. In the example above, /electronics/tv_and_video/
and /electronics
.
Implementations§
source§impl Facet
impl Facet
sourcepub fn encoded_str(&self) -> &str
pub fn encoded_str(&self) -> &str
Returns a binary representation of the facet.
In this representation, 0u8
is used as a separator
and the string parts of the facet are unescaped.
(The first /
is not encoded at all).
This representation has the benefit of making it possible to express “being a child of a given facet” as a range over the term ordinals.
sourcepub fn from_encoded(encoded_bytes: Vec<u8>) -> Result<Facet, FromUtf8Error>
pub fn from_encoded(encoded_bytes: Vec<u8>) -> Result<Facet, FromUtf8Error>
Creates a Facet
from its binary representation.
sourcepub fn from_text<T>(path: &T) -> Result<Facet, FacetParseError>
pub fn from_text<T>(path: &T) -> Result<Facet, FacetParseError>
Parse a text representation of a facet.
If one of the segments of this path
contains a /
, it should be escaped
using an anti-slash \
.
sourcepub fn from_path<Path>(path: Path) -> Facet
pub fn from_path<Path>(path: Path) -> Facet
Returns a Facet
from an iterator over the different
steps of the facet path.
The steps are expected to be unescaped.
sourcepub fn is_prefix_of(&self, other: &Facet) -> bool
pub fn is_prefix_of(&self, other: &Facet) -> bool
Returns true
if other is a strict
subfacet of self
.
Disclaimer: By strict we mean that the relation is not reflexive.
/happy
is not a prefix of /happy
.
sourcepub fn to_path_string(&self) -> String
pub fn to_path_string(&self) -> String
This function is the inverse of Facet::from(&str).
Trait Implementations§
source§impl BinarySerializable for Facet
impl BinarySerializable for Facet
source§impl<'de> Deserialize<'de> for Facet
impl<'de> Deserialize<'de> for Facet
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl From<Facet> for OwnedValue
impl From<Facet> for OwnedValue
source§fn from(facet: Facet) -> OwnedValue
fn from(facet: Facet) -> OwnedValue
source§impl Ord for Facet
impl Ord for Facet
source§impl PartialEq for Facet
impl PartialEq for Facet
source§impl PartialOrd for Facet
impl PartialOrd for Facet
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl ValueDeserialize for Facet
impl ValueDeserialize for Facet
source§fn deserialize<'de, D>(deserializer: D) -> Result<Self, DeserializeError>where
D: ValueDeserializer<'de>,
fn deserialize<'de, D>(deserializer: D) -> Result<Self, DeserializeError>where
D: ValueDeserializer<'de>,
impl Eq for Facet
impl StructuralPartialEq for Facet
Auto Trait Implementations§
impl Freeze for Facet
impl RefUnwindSafe for Facet
impl Send for Facet
impl Sync for Facet
impl Unpin for Facet
impl UnwindSafe for Facet
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.