pub struct MojoEmbedder { /* private fields */ }Expand description
Bridge to a Mojo-compiled embedding binary for high-throughput batch embedding.
The binary must implement the JSON line protocol described at the top of
this file. Spawn it once via MojoEmbedder::new and reuse it across
calls — each [embed_batch] call is a single subprocess invocation.
Implementations§
Source§impl MojoEmbedder
impl MojoEmbedder
Sourcepub fn new(binary_path: impl AsRef<Path>) -> Self
pub fn new(binary_path: impl AsRef<Path>) -> Self
Create a new embedder pointing at the given Mojo binary.
Sourcepub async fn embed_batch(
&self,
texts: Vec<String>,
) -> Result<Vec<Vec<f32>>, OxideError>
pub async fn embed_batch( &self, texts: Vec<String>, ) -> Result<Vec<Vec<f32>>, OxideError>
Embed a batch of strings.
Spawns the Mojo binary, feeds it a single-line JSON request on stdin, and parses the single-line JSON response from stdout.
§Errors
Returns an error if the binary cannot be spawned, exits non-zero, or returns malformed JSON.
Auto Trait Implementations§
impl Freeze for MojoEmbedder
impl RefUnwindSafe for MojoEmbedder
impl Send for MojoEmbedder
impl Sync for MojoEmbedder
impl Unpin for MojoEmbedder
impl UnsafeUnpin for MojoEmbedder
impl UnwindSafe for MojoEmbedder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more