Skip to main content

Wire

Trait Wire 

Source
pub trait Wire:
    Clone
    + WasmCompatSend
    + WasmCompatSync
    + 'static {
    type Op: Operation;
    type Payload: WasmCompatSend + 'static;
    type Frame: WasmCompatSend + 'static;
    type Decoder<'id>: Decoder<'id, Self::Op, Self::Frame> + WasmCompatSend;
    type Reassembler: Reassemble<Self::Frame> + Serves<Self::Op>;

    // Required methods
    fn describe(&self) -> Descriptor<'_>;
    fn encode(
        &self,
        request: Request<Self>,
        mode: Mode,
    ) -> Result<Self::Payload, EncodeError>;
    fn decoder<'id>(&self) -> Self::Decoder<'id>;

    // Provided method
    fn reassembler(&self) -> Self::Reassembler { ... }
}
Expand description

A provider endpoint: plain data that encodes requests and names a decoder for each reply.

No transport, no future, no type parameter. Implementations are plain data (Clone + PartialEq + Debug + Serialize + Deserialize, with credentials held in Secret), so a host can store one in a scene, a component, or a config file. Clone is a supertrait: the driver clones the wire into every call’s 'static stream.

Required Associated Types§

Source

type Op: Operation

The operation this wire performs.

Source

type Payload: WasmCompatSend + 'static

What Self::encode produces for the transport to send.

Source

type Frame: WasmCompatSend + 'static

One unit of a reply, as the transport delivers it.

Source

type Decoder<'id>: Decoder<'id, Self::Op, Self::Frame> + WasmCompatSend

The decoder for one of its replies, branded with that reply.

Source

type Reassembler: Reassemble<Self::Frame> + Serves<Self::Op>

What rebuilds a reply’s provider document from its frames when the transport reports no whole document, as for a stream. The driver feeds it every frame and records what it finishes with as raw. A wire whose operation’s decoders record raw themselves names document::Unreassembled; a completion wire cannot, because it does not Serve completions.

Required Methods§

Source

fn describe(&self) -> Descriptor<'_>

What the wire says about itself.

Source

fn encode( &self, request: Request<Self>, mode: Mode, ) -> Result<Self::Payload, EncodeError>

The request to send. Pure: it may read self, request and mode, and nothing else. A request that cannot be built is an EncodeError, which always reports as a request failure.

Source

fn decoder<'id>(&self) -> Self::Decoder<'id>

A fresh decoder for one reply.

Provided Methods§

Source

fn reassembler(&self) -> Self::Reassembler

A fresh reassembler for one reply. A wire that picks its API per reply builds the matching one.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Wire for CachedContents

Source§

impl Wire for rig_core::providers::ollama::chat::Chat

Source§

impl Wire for rig_core::providers::openai::wire::Chat

Source§

type Op = Completion

Source§

type Payload = Encoded

Source§

type Frame = WireFrame

Source§

type Decoder<'id> = ChatDecoder

Source§

type Reassembler = ChatCompletion

Source§

impl Wire for CohereChat

Source§

impl Wire for CopilotWire

Source§

impl Wire for rig_core::providers::cohere::embeddings::Embeddings

Source§

impl Wire for rig_core::providers::gemini::embedding::Embeddings

Source§

impl Wire for rig_core::providers::ollama::embedding::Embeddings

Source§

impl Wire for rig_core::providers::openai::wire::Embeddings

Source§

impl Wire for rig_core::providers::voyageai::wire::Embeddings

Source§

impl Wire for GenerateContent

Source§

impl Wire for ImageEmbeddings

Source§

impl Wire for rig_core::providers::gemini::image_generation::Images

Available on crate feature image only.
Source§

impl Wire for rig_core::providers::openai::wire::Images

Available on crate feature image only.
Source§

impl Wire for InteractionResume

Source§

impl Wire for Interactions

Source§

impl Wire for InteractionsModels

Source§

impl Wire for Messages

Source§

impl Wire for MockScript

Available on crate feature test-utils only.
Source§

impl Wire for rig_core::providers::anthropic::modality::Models

Source§

impl Wire for rig_core::providers::copilot::model_listing::Models

Source§

impl Wire for rig_core::providers::gemini::model_listing::Models

Source§

impl Wire for rig_core::providers::ollama::model_listing::Models

Source§

impl Wire for rig_core::providers::openai::wire::Models

Source§

impl Wire for NativeChat

Source§

impl Wire for OpenAiWire

Source§

impl Wire for rig_core::providers::openai::wire::Rerank

Source§

impl Wire for rig_core::providers::voyageai::wire::Rerank

Source§

impl Wire for Responses

Source§

impl Wire for Speech

Available on crate feature audio only.
Source§

impl Wire for rig_core::providers::gemini::transcription::Transcriptions

Source§

impl Wire for rig_core::providers::openai::wire::Transcriptions

Source§

impl Wire for rig_core::providers::anthropic::modality::Verify

Source§

impl Wire for rig_core::providers::openai::wire::Verify

Source§

impl Wire for VerifyKey

Source§

impl<Op: Operation<Emit = Free>> Wire for Local<Op>