1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pub use semantic::Semantic;

use crate::UniffiCustomTypeConverter;

pub(crate) mod semantic;

#[derive(Debug, Clone)]
pub struct Embedding(pub Vec<f32>);

impl Embedding {
    pub fn len(&self) -> usize {
        self.0.len()
    }

    pub fn iter(&self) -> std::slice::Iter<'_, f32> {
        self.0.iter()
    }
}

impl UniffiCustomTypeConverter for Embedding {
    type Builtin = Vec<f32>;

    fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> {
        Ok(Embedding(val))
    }

    // Convert our custom type to Builtin
    fn from_custom(obj: Self) -> Self::Builtin {
        obj.0
    }
}