Skip to main content

Key

Struct Key 

Source
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

Source

pub fn null() -> Key

The key for null.

Source

pub fn bool(v: bool) -> Key

The key for a boolean.

Source

pub fn int(v: i64) -> Key

The key for an integer.

Source

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.

Source

pub fn text(v: &str) -> Key

The key for a string.

Source

pub fn text_bytes(v: &[u8]) -> Key

The key for a string that is already bytes.

Source

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.

Source

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.

Source

pub fn as_bytes(&self) -> &[u8]

The bytes this is filed under.

Source

pub fn is_too_long(&self) -> bool

Whether this key is too long to file.

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Key

Source§

impl PartialEq for Key

Source§

fn eq(&self, other: &Key) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnsafeUnpin for Key

§

impl UnwindSafe for Key

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.