Skip to main content

Lazy

Struct Lazy 

Source
pub struct Lazy { /* private fields */ }
Expand description

An embedder made on first use, so a large vector file is read when memory is first asked for, off the daemon’s event loop, and not when the settings are read. A failure to make it is kept and returned by every call.

Implementations§

Source§

impl Lazy

Source

pub fn new( model: String, make: impl Fn() -> Result<Box<dyn Embedder>, Error> + Send + Sync + 'static, ) -> Lazy

model must be the name the made embedder gives.

Source

pub fn static_vectors(path: PathBuf) -> Lazy

Word vectors from path, read on first use.

Trait Implementations§

Source§

impl Debug for Lazy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Embedder for Lazy

Source§

fn model(&self) -> &str

Names the model, so vectors from another one are never compared with these: static:<file name> or local:<program>.
Source§

fn dimension(&self) -> usize

Source§

fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, Error>

One vector per text, in order, each dimension long. A text the model has nothing for gets zeros.

Auto Trait Implementations§

§

impl !Freeze for Lazy

§

impl !RefUnwindSafe for Lazy

§

impl !UnwindSafe for Lazy

§

impl Forget for Lazy

§

impl Move for Lazy

§

impl Send for Lazy
where RawVecInner: Send, BoxRaw<dyn Fn() -> Result<Box<dyn Embedder>, Error> + Sync + Send>: Send, OnceLock<Result<Box<dyn Embedder>, Error>>: Send,

§

impl Sync for Lazy
where RawVecInner: Sync, BoxRaw<dyn Fn() -> Result<Box<dyn Embedder>, Error> + Sync + Send>: Sync, OnceLock<Result<Box<dyn Embedder>, Error>>: Sync,

§

impl Unpin for Lazy
where *const u8 is !null: Unpin, Box<dyn Fn() -> Result<Box<dyn Embedder>, Error> + Sync + Send>: Unpin, Align4<u32>: Unpin, Box<dyn Embedder>: Unpin,

§

impl UnsafeUnpin for Lazy

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.