diff --git a/rust/libs/algorithm/src/base.rs b/rust/libs/algorithm/src/base.rs index fc5342c210..5435aa8194 100644 --- a/rust/libs/algorithm/src/base.rs +++ b/rust/libs/algorithm/src/base.rs @@ -1,11 +1,13 @@ pub mod algorithm { use anyhow::Result; - pub trait Base { - fn search(&self, v: &Vec, p: Option<&SP>) -> Result<&SR>; - fn insert(&self, v: &Vec, id: &U, p: Option<&IP>) -> Result<&IR>; - fn update(&self, v: &Vec, id: &U, p: Option<&UP>) -> Result<&UR>; - fn remove(&self, id: &U, p: Option<&RP>) -> Result<&RR>; - fn commit(&self, p: Option<&CP>) -> Result<&CR>; + pub trait Base { + fn search(&self, v: &Vec, p: Option) -> Result; + fn insert(&self, v: &Vec, id: &U, p: Option) -> Result; + fn update(&self, v: &Vec, id: &U, p: Option) -> Result; + fn remove(&self, id: &U, p: Option) -> Result; + fn commit(&self, p: Option) -> Result; + + fn new(p: Option

) -> Result; } } diff --git a/rust/libs/algorithm/src/ngt.rs b/rust/libs/algorithm/src/ngt.rs index f1b7ebf8d0..c3f562b463 100644 --- a/rust/libs/algorithm/src/ngt.rs +++ b/rust/libs/algorithm/src/ngt.rs @@ -27,9 +27,9 @@ pub mod ngt { num: u32, } - #[derive(Debug)] + #[derive(Debug)] pub struct InsertParam {} - + #[derive(Debug)] pub struct UpdateParam {} @@ -37,12 +37,34 @@ pub mod ngt { pub struct RemoveParam {} #[derive(Debug)] - pub struct CommitParam{} + pub struct CommitParam {} #[derive(Debug)] pub struct NGTParam {} - impl Base for NGT { - fn search() + impl + Base< + f32, + String, + SearchParam, + SearchResponse, + InsertParam, + (), + UpdateParam, + (), + RemoveParam, + (), + CommitParam, + (), + NGTParam, + > for NGT + { + fn search(&self, v: &Vec, p: Option) -> Result; + fn insert(&self, v: &Vec, id: &U, p: Option) -> Result<()>; + fn update(&self, v: &Vec, id: &U, p: Option) -> Result<()>; + fn remove(&self, id: &U, p: Option) -> Result<()>; + fn commit(&self, p: Option) -> Result<()>; + + fn new(p: Option) -> Result; } -} \ No newline at end of file +}