Skip to main content

Endpoint

Trait Endpoint 

Source
pub trait Endpoint: Debug {
    // Required methods
    fn readiness(&self, token: Token) -> &Readiness;
    fn readiness_mut(&mut self, token: Token) -> &mut Readiness;
    fn socket(&self, token: Token) -> Option<&TcpStream>;
    fn end_stream<L: ListenerHandler + L7ListenerHandler>(
        &mut self,
        token: Token,
        stream: usize,
        context: &mut Context<L>,
    );
    fn start_stream<L: ListenerHandler + L7ListenerHandler>(
        &mut self,
        token: Token,
        stream: usize,
        context: &mut Context<L>,
    ) -> bool;
}

Required Methods§

Source

fn readiness(&self, token: Token) -> &Readiness

Source

fn readiness_mut(&mut self, token: Token) -> &mut Readiness

Source

fn socket(&self, token: Token) -> Option<&TcpStream>

Returns the underlying TCP socket for the peer side of a stream.

Used by access-log emission to capture TCP_INFO RTT for the side the caller does NOT own directly: a frontend connection (Position::Server) reads the backend socket through this method, and a backend connection (Position::Client) reads the frontend socket the same way. token is ignored by [super::connection::EndpointServer] (which has a single frontend connection) and used as a key by [super::connection::EndpointClient] (which keys backends by token). Returns None when the token doesn’t resolve, mirroring the existing fallback paths in readiness/readiness_mut.

Source

fn end_stream<L: ListenerHandler + L7ListenerHandler>( &mut self, token: Token, stream: usize, context: &mut Context<L>, )

If end_stream is called on a client it means the stream has PROPERLY finished, the server has completed serving the response and informs the endpoint that this stream won’t be used anymore. If end_stream is called on a server it means the stream was BROKEN, the client was most likely disconnected or encountered an error it is for the server to decide if the stream can be retried or an error should be sent. It should be GUARANTEED that all bytes from the backend were read. However it is almost certain that all bytes were not already sent to the client.

Source

fn start_stream<L: ListenerHandler + L7ListenerHandler>( &mut self, token: Token, stream: usize, context: &mut Context<L>, ) -> bool

If start_stream is called on a client it means the stream should be attached to this endpoint, the stream might be recovering from a disconnection, in any case at this point its response MUST be empty. If the start_stream is called on a H2 server it means the stream is a server push and its request MUST be empty. Returns false if the stream could not be started (e.g. max concurrent streams reached).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§