pub struct TranslationEngine { /* private fields */ }Expand description
Stateless request/response translator that routes through the neutral IR.
Implementations§
Source§impl TranslationEngine
impl TranslationEngine
Sourcepub fn new(registry: FormatRegistry) -> Self
pub fn new(registry: FormatRegistry) -> Self
Creates an engine from an explicit buffered codec registry.
Sourcepub fn with_registries(
registry: FormatRegistry,
stream_registry: StreamCodecRegistry,
) -> Self
pub fn with_registries( registry: FormatRegistry, stream_registry: StreamCodecRegistry, ) -> Self
Creates an engine from explicit buffered and streaming codec registries.
Sourcepub fn decode_request(
&self,
source: impl Into<FormatId>,
body: &Value,
policy: &TranslationPolicy,
) -> Result<RequestIrOutput>
pub fn decode_request( &self, source: impl Into<FormatId>, body: &Value, policy: &TranslationPolicy, ) -> Result<RequestIrOutput>
Decodes a request body into the neutral request IR.
Sourcepub fn encode_request(
&self,
target: impl Into<FormatId>,
request: &LlmRequest,
policy: &TranslationPolicy,
) -> Result<TranslationOutput>
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.
Sourcepub fn translate_request(
&self,
source: impl Into<FormatId>,
target: impl Into<FormatId>,
body: &Value,
policy: &TranslationPolicy,
) -> Result<TranslationOutput>
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.
Sourcepub fn decode_response(
&self,
source: impl Into<FormatId>,
body: &Value,
policy: &TranslationPolicy,
) -> Result<ResponseIrOutput>
pub fn decode_response( &self, source: impl Into<FormatId>, body: &Value, policy: &TranslationPolicy, ) -> Result<ResponseIrOutput>
Decodes a response body into the neutral response IR.
Sourcepub fn encode_response(
&self,
target: impl Into<FormatId>,
response: &LlmResponse,
policy: &TranslationPolicy,
) -> Result<TranslationOutput>
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.
Sourcepub fn translate_response(
&self,
source: impl Into<FormatId>,
target: impl Into<FormatId>,
body: &Value,
policy: &TranslationPolicy,
) -> Result<TranslationOutput>
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.
Sourcepub fn translate_event(
&self,
state: &mut StreamTranslationState,
source: impl Into<FormatId>,
target: impl Into<FormatId>,
event: &Value,
) -> Result<Vec<Value>>
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.
Sourcepub fn finish_stream(
&self,
state: &mut StreamTranslationState,
target: impl Into<FormatId>,
) -> Result<Vec<Value>>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for TranslationEngine
impl !UnwindSafe for TranslationEngine
impl Freeze for TranslationEngine
impl Send for TranslationEngine
impl Sync for TranslationEngine
impl Unpin for TranslationEngine
impl UnsafeUnpin for TranslationEngine
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