Skip to main content

ModelHttpClient

Trait ModelHttpClient 

Source
pub trait ModelHttpClient: Send + Sync {
    // Required method
    fn send<'life0, 'async_trait>(
        &'life0 self,
        request: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, ModelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn send_event_stream<'life0, 'async_trait>(
        &'life0 self,
        request: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Value>, ModelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn send_event_stream_incremental<'life0, 'async_trait>(
        &'life0 self,
        request: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ModelEventStream, ModelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn send_websocket_event_stream_incremental<'life0, 'async_trait>(
        &'life0 self,
        request: HttpRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ModelEventStream, ModelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn websocket_event_session(
        &self,
    ) -> Box<dyn ModelWebSocketEventSession + '_> { ... }
}
Expand description

Async HTTP client abstraction used by production model adapters.

Required Methods§

Source

fn send<'life0, 'async_trait>( &'life0 self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, ModelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a JSON model request.

§Errors

Returns an error when transport, status, or response decoding fails.

Provided Methods§

Source

fn send_event_stream<'life0, 'async_trait>( &'life0 self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<Vec<Value>, ModelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a server-sent events model request and return JSON data: payloads.

§Errors

Returns an error when transport, status, or event decoding fails.

Source

fn send_event_stream_incremental<'life0, 'async_trait>( &'life0 self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<ModelEventStream, ModelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a server-sent events model request and return events as they arrive.

§Errors

Returns an error when transport setup fails.

Source

fn send_websocket_event_stream_incremental<'life0, 'async_trait>( &'life0 self, request: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<ModelEventStream, ModelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a WebSocket model request and return JSON text-frame events as they arrive.

§Errors

Returns an error when WebSocket transport setup fails.

Source

fn websocket_event_session(&self) -> Box<dyn ModelWebSocketEventSession + '_>

Create a session that may reuse WebSocket transport state across sequential requests.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§