pub struct EdgeLlm { /* private fields */ }Expand description
The flat FFI-friendly facade (ADR-001, ADR-009, ADR-010).
Annotated for all three binding surfaces:
uniffi::Object(native) → opaque UniFFI / React Native handlefrb(opaque)(native) → opaque Dart handle via FRB v2 codegenwasm_bindgen(wasm32) → satisfiesIntoWasmAbi/WasmDescribeso that#[wasm_bindgen] impl EdgeLlm { ... }compiles
Implementations§
Source§impl EdgeLlm
UniFFI-exported methods: constructors, blocking chat, and reset.
impl EdgeLlm
UniFFI-exported methods: constructors, blocking chat, and reset.
Dart uses the edge_llm_* free-function wrappers below so FRB does not
need to parse the UniFFI-decorated impl block after macro expansion.
Sourcepub fn local(model_uri: String) -> Result<Self, SdkError>
pub fn local(model_uri: String) -> Result<Self, SdkError>
Construct with the local Candle engine (air-gapped, ADR-002/004).
If model_uri is non-empty, loads the GGUF at that path via
CandleEngine::from_path (consumer-supplied model, ADR-002).
Pass an empty string to use a deterministic toy model for development
and testing — the toy generates gibberish but exercises the full
binding layer end-to-end.
Returns Err(SdkError) if model_uri is non-empty but the file
cannot be parsed (missing, malformed GGUF, incompatible tensor shapes).
An empty model_uri never fails.
The permissive signature verifier used here is intentional: it lets the
binding layer be exercised without a signed model artifact. A production
deployment should substitute a real SignatureVerifier backed by the
platform keystore.
Sourcepub fn cloud(model: String, api_key: String) -> Self
pub fn cloud(model: String, api_key: String) -> Self
Construct with a frontier cloud backend (opt-in, ADR-010).
model uses the routing prefix: "openai/gpt-4o",
"anthropic/claude-sonnet-4-6", "ollama/llama3",
"gemini/gemini-2.0-flash", or any OpenAI-compat base URL.
api_key must come from the platform keystore — never embedded.
Native only (React Native / Dart native). On wasm32 this constructor
does not exist — the web surface exposes a throwing cloud instead
(see the wasm32 impl block below and the ADR-010 amendment).
Source§impl EdgeLlm
Streaming via callback interface — exported for React Native (UniFFI).
impl EdgeLlm
Streaming via callback interface — exported for React Native (UniFFI).
Separated from the main block because UniFFI cannot export impl FnMut.
Sourcepub fn ask_stream_cb(
&self,
prompt: String,
handler: Box<dyn StreamHandler>,
) -> Result<(), SdkError>
pub fn ask_stream_cb( &self, prompt: String, handler: Box<dyn StreamHandler>, ) -> Result<(), SdkError>
Stream tokens to a StreamHandler callback (React Native path).
Returns an error on network/auth/engine failure so callers are not left waiting for a stream that will never arrive.
Trait Implementations§
Source§impl<UT> LowerError<UT> for EdgeLlm
impl<UT> LowerError<UT> for EdgeLlm
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for EdgeLlm
impl<UT> LowerReturn<UT> for EdgeLlm
Source§type ReturnType = <Arc<EdgeLlm> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<EdgeLlm> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
Source§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Auto Trait Implementations§
impl !RefUnwindSafe for EdgeLlm
impl !UnwindSafe for EdgeLlm
impl Freeze for EdgeLlm
impl Send for EdgeLlm
impl Sync for EdgeLlm
impl Unpin for EdgeLlm
impl UnsafeUnpin for EdgeLlm
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> DartSafe for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more