pub struct Key(/* private fields */);Expand description
A value as an index looks it up.
Built from what the caller is searching for, or from what was found at a path in a document being written. The two go through the same code on purpose, because a query that encodes its argument differently from the way the write encoded the document is a query that finds nothing and says nothing about why.
Implementations§
Source§impl Key
impl Key
Sourcepub fn float(v: f64) -> Key
pub fn float(v: f64) -> Key
The key for a float.
A float and an integer that name the same number get the same key, so
7.0 and 7 are one key and a search for either finds both.
Sourcepub fn text_bytes(v: &[u8]) -> Key
pub fn text_bytes(v: &[u8]) -> Key
The key for a string that is already bytes.
Sourcepub fn word(v: &str) -> Option<Key>
pub fn word(v: &str) -> Option<Key>
The key one word is filed under in a text index, or None if this is
not one word.
A search against a text index goes through this rather than
Key::text, because a text index folds case when it files a document
and a search that does not fold it finds nothing and says nothing about
why. Anything that is not letters and digits is a separator, so a phrase
is two words and answers None: matching one is a search this index
cannot answer on its own, rather than a search for the first word.
Sourcepub fn of(v: Value<'_>) -> Option<Key>
pub fn of(v: Value<'_>) -> Option<Key>
The key for a value found in a document, or None if it is a container
and so has no equality key.
Sourcepub fn is_too_long(&self) -> bool
pub fn is_too_long(&self) -> bool
Whether this key is too long to file.