Session

Trait Session 

Source
pub trait Session<E> {
    // Required methods
    fn handle_request(
        &self,
        request: &[u8],
    ) -> impl Future<Output = Result<(), E>>;
    fn close(self) -> impl Future<Output = ()>;
}
Expand description

The server-side representation of a connection to a Client.

For each Client that wants to connect to a perspective_server::Server, a dedicated Session must be created. The Session handles routing messages emitted by the perspective_server::Serverve_server::Server, as well as owning any resources the [Client`] may request.

Required Methods§

Source

fn handle_request(&self, request: &[u8]) -> impl Future<Output = Result<(), E>>

Handle an incoming request from the Client. Calling Session::handle_request will result in the send_response parameter which was used to construct this Session to fire one or more times.

§Arguments
  • request An incoming request message, generated from a Client::new’s send_request handler (which may-or-may-not be local).
Source

fn close(self) -> impl Future<Output = ()>

Close this Session, cleaning up any callbacks (e.g. arguments provided to Session::handle_request) and resources (e.g. views returned by a call to Table::view).

Dropping a Session outside of the context of Session::close will cause a tracing error-level log to be emitted, but won’t fail. They will, however, leak.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§