[][src]Trait fuse_rust::Fuseable

pub trait Fuseable {
    pub fn properties(&self) -> Vec<FuseProperty>;
pub fn lookup(&self, key: &str) -> Option<&str>; }

Implementable trait for user defined structs, requires two methods to me implemented. A properties method that should return a list of FuseProperties. and a lookup method which should return the value of field, provided the field name.

Examples:

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
        }
    }
}

Required methods

pub fn properties(&self) -> Vec<FuseProperty>[src]

Returns a list of FuseProperty that contains the field name and its corresponding weight

pub fn lookup(&self, key: &str) -> Option<&str>[src]

Provided a field name as argument, returns the value of the field. eg book.loopkup("author") === book.author

Loading content...

Implementors

Loading content...