Skip to main content

TranslationEngine

Struct TranslationEngine 

Source
pub struct TranslationEngine { /* private fields */ }
Expand description

Stateless request/response translator that routes through the neutral IR.

Implementations§

Source§

impl TranslationEngine

Source

pub fn new(registry: FormatRegistry) -> Self

Creates an engine from an explicit buffered codec registry.

Source

pub fn with_registries( registry: FormatRegistry, stream_registry: StreamCodecRegistry, ) -> Self

Creates an engine from explicit buffered and streaming codec registries.

Source

pub fn decode_request( &self, source: impl Into<FormatId>, body: &Value, policy: &TranslationPolicy, ) -> Result<RequestIrOutput>

Decodes a request body into the neutral request IR.

Source

pub fn encode_request( &self, target: impl Into<FormatId>, request: &LlmRequest, policy: &TranslationPolicy, ) -> Result<TranslationOutput>

Encodes a neutral request IR into a target wire format.

Source

pub fn translate_request( &self, source: impl Into<FormatId>, target: impl Into<FormatId>, body: &Value, policy: &TranslationPolicy, ) -> Result<TranslationOutput>

Translates a request body from source format to target format.

Source

pub fn decode_response( &self, source: impl Into<FormatId>, body: &Value, policy: &TranslationPolicy, ) -> Result<ResponseIrOutput>

Decodes a response body into the neutral response IR.

Source

pub fn encode_response( &self, target: impl Into<FormatId>, response: &LlmResponse, policy: &TranslationPolicy, ) -> Result<TranslationOutput>

Encodes a neutral response IR into a target wire format.

Source

pub fn translate_response( &self, source: impl Into<FormatId>, target: impl Into<FormatId>, body: &Value, policy: &TranslationPolicy, ) -> Result<TranslationOutput>

Translates a response body from source format to target format.

Source

pub fn translate_event( &self, state: &mut StreamTranslationState, source: impl Into<FormatId>, target: impl Into<FormatId>, event: &Value, ) -> Result<Vec<Value>>

Translates one streaming source event into zero or more target events.

Source

pub fn finish_stream( &self, state: &mut StreamTranslationState, target: impl Into<FormatId>, ) -> Result<Vec<Value>>

Finishes target-provider stream emission after the source stream closes.

Trait Implementations§

Source§

impl Default for TranslationEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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.