[][src]Struct fuse_rust::FuseProperty

pub struct FuseProperty {
    pub value: String,
    pub weight: f64,
}

Defines the fuseproperty object to be returned as part of the list returned by properties() implemented by the Fuseable trait.

Examples:

Basic Usage:

use fuse_rust::{ Fuse, Fuseable, FuseProperty };
struct Book<'a> {
    title: &'a str,
    author: &'a str,
}
 
impl Fuseable for Book<'_>{
    fn properties(&self) -> Vec<FuseProperty> {
        return vec!(
            FuseProperty{value: String::from("title"), weight: 0.3},
            FuseProperty{value: String::from("author"), weight: 0.7},
        )
    }
    fn lookup(&self, key: &str) -> Option<&str> {
        return match key {
            "title" => Some(self.title),
            "author" => Some(self.author),
            _ => None
        }
    }
}

Fields

value: String

The name of the field with an associated weight in the search.

weight: f64

The weight associated with the specified field.

Implementations

impl FuseProperty[src]

pub fn init(value: &str) -> Self[src]

create a fuse property with weight 1.0 and a string reference.

pub fn init_with_weight(value: &str, weight: f64) -> Self[src]

create a fuse property with a specified weight and string reference.

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.