[−][src]Trait fuse_rust::Fuseable
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
fn properties(&self) -> Vec<FuseProperty>
Returns a list of FuseProperty that contains the field name and its corresponding weight
fn lookup(&self, key: &str) -> Option<&str>
Provided a field name as argument, returns the value of the field. eg book.loopkup("author") === book.author