Skip to main content

Operation

Trait Operation 

Source
pub trait Operation: Sized + 'static {
    type Request: WasmCompatSend + 'static;
    type Event: WasmCompatSend + 'static;
    type End: WasmCompatSend + 'static;
    type Response: WasmCompatSend + 'static;
    type Fold: Fold<Self> + WasmCompatSend + 'static;
    type Emit: Emit<Self>;

    // Required method
    fn fold(request: &Self::Request, call: &mut Call<'_>) -> Self::Fold;

    // Provided method
    fn validate(_request: &Self::Request) -> Result<(), ProviderError> { ... }
}
Expand description

An operation: what goes in, what comes out event by event, what ends a reply, and how those fold into one response.

Implemented once per operation, never per provider, so every provider of an operation is interchangeable behind a DynModel.

Required Associated Types§

Source

type Request: WasmCompatSend + 'static

The normalized request this operation accepts.

Source

type Event: WasmCompatSend + 'static

One decoded step of a reply.

Source

type End: WasmCompatSend + 'static

What the provider sends when it ends the reply. A fold needs one to produce a response, so a reply that stopped early has none.

Source

type Response: WasmCompatSend + 'static

The normalized response the events and the end fold into.

Source

type Fold: Fold<Self> + WasmCompatSend + 'static

One reply’s state: it absorbs the events the consumer sees, then folds them with the end into the response.

Source

type Emit: Emit<Self>

Who builds the events: Free for events a decoder writes itself, Assembled for the completion events only the writer’s part handles build.

Required Methods§

Source

fn fold(request: &Self::Request, call: &mut Call<'_>) -> Self::Fold

The state for one reply to request, before its first frame. The call says who answers and in which mode; an operation that records telemetry opens its span here and hands it to Call::instrument.

Provided Methods§

Source

fn validate(_request: &Self::Request) -> Result<(), ProviderError>

Reject a request no provider of this operation can answer. The driver calls it before the request is encoded, so a rejected request reaches no wire or transport. Accepts every request by default.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Operation for AudioGeneration

Source§

impl Operation for Completion

Source§

impl Operation for ContextCache

Source§

impl Operation for Embedding

Source§

impl Operation for ImageEmbedding

Source§

impl Operation for ImageGeneration

Source§

impl Operation for ModelListing

Source§

impl Operation for Rerank

Source§

impl Operation for Transcription

Source§

impl Operation for Verify