pub trait SessionBackend: Send + 'static {
// Required methods
fn id(&self) -> &str;
fn model_id(&self) -> &ModelId;
fn send(
&mut self,
input: SessionInput,
) -> impl Future<Output = Result<(), KitError>> + Send + '_;
fn recv(
&mut self,
) -> impl Future<Output = Result<SessionEvent, KitError>> + Send + '_;
fn close(self) -> impl Future<Output = Result<(), KitError>> + Send;
}Expand description
Public implementation contract for one unique provider-native session.
Caller models return their concrete session implementation directly through
crate::ModelBackend::Session.
Sessions are unique, mutable, and non-Clone. Consuming close settles the session transport; the Provider retains separate shared shutdown authority. Ordinary multi-turn generation instead uses messages and continuation.
See the complete native turn for service setup and cleanup,
or crate::ProviderBackend for an executable caller-owned session.
Required Methods§
Sourcefn id(&self) -> &str
fn id(&self) -> &str
Stable session identifier.
See crate::SessionBackend for a complete example.
Sourcefn model_id(&self) -> &ModelId
fn model_id(&self) -> &ModelId
Exact selected model.
See crate::SessionBackend for a complete example.
Sourcefn send(
&mut self,
input: SessionInput,
) -> impl Future<Output = Result<(), KitError>> + Send + '_
fn send( &mut self, input: SessionInput, ) -> impl Future<Output = Result<(), KitError>> + Send + '_
Sends interactive input.
§Errors
Returns the owning input, unsupported, closed, transport, deadline, service-rejection, or protocol error.
See the complete session turn for bounded observation and cleanup.
Sourcefn recv(
&mut self,
) -> impl Future<Output = Result<SessionEvent, KitError>> + Send + '_
fn recv( &mut self, ) -> impl Future<Output = Result<SessionEvent, KitError>> + Send + '_
Receives the next interactive event.
A delta or usage event does not finish the turn. Continue receiving until its terminal event, as in the complete session turn.
§Errors
Returns the owning input, unsupported, closed, transport, deadline, service-rejection, or protocol error.
See the complete session turn for bounded observation and cleanup.
Sourcefn close(self) -> impl Future<Output = Result<(), KitError>> + Send
fn close(self) -> impl Future<Output = Result<(), KitError>> + Send
Closes the unique session and its transport.
Consuming close does not make the session reusable, even when it fails.
§Errors
Returns the owning input, unsupported, closed, transport, deadline, service-rejection, or protocol error.
See the complete session turn for bounded observation and cleanup.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".