Skip to main content

BoxedEmbedder

Struct BoxedEmbedder 

Source
pub struct BoxedEmbedder<F>
where F: Fn(&[&str]) -> Vec<Vec<f32>> + Send + Sync,
{ /* private fields */ }
Expand description

Adapter that wraps any Fn(&[&str]) -> Vec<Vec<f32>> closure into an Embedder.

Useful when the embedding source is an HTTP client, an ONNX session, a Python callback (via PyO3), or any other resource the caller already manages.

Implementations§

Source§

impl<F> BoxedEmbedder<F>
where F: Fn(&[&str]) -> Vec<Vec<f32>> + Send + Sync,

Source

pub fn new(f: F) -> Self

Wrap a closure as an Embedder with the default name "boxed".

Source

pub fn named(f: F, name: impl Into<String>) -> Self

Wrap a closure as an Embedder with a caller-supplied name (returned by Embedder::id for diagnostic output).

Trait Implementations§

Source§

impl<F> Embedder for BoxedEmbedder<F>
where F: Fn(&[&str]) -> Vec<Vec<f32>> + Send + Sync,

Source§

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

Embed each text in texts. The returned vector at position i is the embedding for texts[i]. All vectors must have the same length (panics on mismatched dimensionality are a contract bug; the caller will validate before computing cosine).
Source§

fn id(&self) -> &str

Optional: a stable identifier for the embedder, included in diagnostic output so a user can tell at a glance which embedder produced a given semantic-axis score.

Auto Trait Implementations§

§

impl<F> Freeze for BoxedEmbedder<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for BoxedEmbedder<F>
where F: RefUnwindSafe,

§

impl<F> Send for BoxedEmbedder<F>

§

impl<F> Sync for BoxedEmbedder<F>

§

impl<F> Unpin for BoxedEmbedder<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for BoxedEmbedder<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for BoxedEmbedder<F>
where F: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Ungil for T
where T: Send,