[][src]Enum avocado::literal::IndexType

pub enum IndexType {
    Ordered(Order),
    Text,
    Hashed,
    Geo2D,
    Geo2DSphere,
    GeoHaystack,
}

An index type, applied to a single indexed field.

let patient_index = doc!{
    "description": IndexType::Text,
    "body.mass": IndexType::Ordered(Order::Ascending),
    "birth_date.year": IndexType::Ordered(Order::Descending),
    "address_gps_coords": IndexType::Geo2DSphere,
};
assert_eq!(patient_index, doc!{
    "description": "text",
    "body.mass": 1,
    "birth_date.year": -1,
    "address_gps_coords": "2dsphere",
});

Variants

Ordered(Order)

An ordered index field.

Text

A language-specific textual index, most useful for freetext searches.

Hashed

Hashed index for hash-based sharding.

Geo2D

2D geospatial index with planar (Euclidean) geometry.

Geo2DSphere

2D geospatial index with spherical geometry.

GeoHaystack

2D geospatial index optimized for very small areas.

Trait Implementations

impl PartialEq<IndexType> for IndexType
[src]

impl Eq for IndexType
[src]

impl Clone for IndexType
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<IndexType> for Bson
[src]

impl Copy for IndexType
[src]

impl Debug for IndexType
[src]

impl Hash for IndexType
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<'a> Deserialize<'a> for IndexType
[src]

let asc_i32 = Bson::I32(1);
let desc_i64 = Bson::I64(-1);
let asc_float = Bson::FloatingPoint(1.0);
let text = Bson::from("text");
let spherical_2d = Bson::from("2dsphere");
let hashed = Bson::from("hashed");

let bad_i64 = Bson::I64(0);
let bad_float = Bson::FloatingPoint(3.14);
let bad_str = Bson::from("Ascending");
let bad_type = Bson::Boolean(true);

assert_eq!(from_bson::<IndexType>(asc_i32)?,
           IndexType::Ordered(Order::Ascending));
assert_eq!(from_bson::<IndexType>(desc_i64)?,
           IndexType::Ordered(Order::Descending));
assert_eq!(from_bson::<IndexType>(asc_float)?,
           IndexType::Ordered(Order::Ascending));
assert_eq!(from_bson::<IndexType>(text)?,
           IndexType::Text);
assert_eq!(from_bson::<IndexType>(spherical_2d)?,
           IndexType::Geo2DSphere);
assert_eq!(from_bson::<IndexType>(hashed)?,
           IndexType::Hashed);

assert!(from_bson::<IndexType>(bad_i64)
        .unwrap_err()
        .to_string()
        .contains("invalid ordering"));
assert!(from_bson::<IndexType>(bad_float)
        .unwrap_err()
        .to_string()
        .contains("invalid ordering"));
assert!(from_bson::<IndexType>(bad_str)
        .unwrap_err()
        .to_string()
        .contains("unrecognized index type"));
assert!(from_bson::<IndexType>(bad_type)
        .unwrap_err()
        .to_string()
        .contains("an ordering integer or an index type string"));

impl Serialize for IndexType
[src]

let asc = IndexType::Ordered(Order::Ascending);
let desc = IndexType::Ordered(Order::Descending);
let haystack = IndexType::GeoHaystack;
let text = IndexType::Text;
let planar_2d = IndexType::Geo2D;
let spherical_2d = IndexType::Geo2DSphere;

assert_eq!(to_bson(&asc)?, Bson::from(asc));
assert_eq!(to_bson(&desc)?, Bson::from(desc));
assert_eq!(to_bson(&haystack)?, Bson::from(haystack));
assert_eq!(to_bson(&text)?, Bson::from(text));
assert_eq!(to_bson(&planar_2d)?, Bson::from(planar_2d));
assert_eq!(to_bson(&spherical_2d)?, Bson::from(spherical_2d));

Auto Trait Implementations

impl Send for IndexType

impl Sync for IndexType

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T> Same for T

type Output = T

Should always be Self