Trait deno_http::HttpPropertyExtractor
source · pub trait HttpPropertyExtractor {
type Listener: 'static;
type Connection;
// Required methods
fn get_listener_for_rid(
state: &mut OpState,
listener_rid: ResourceId
) -> Result<Self::Listener, AnyError>;
fn get_connection_for_rid(
state: &mut OpState,
connection_rid: ResourceId
) -> Result<Self::Connection, AnyError>;
fn listen_properties_from_listener(
listener: &Self::Listener
) -> Result<HttpListenProperties, Error>;
fn listen_properties_from_connection(
connection: &Self::Connection
) -> Result<HttpListenProperties, Error>;
fn accept_connection_from_listener<'life0, 'async_trait>(
listener: &'life0 Self::Listener
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, AnyError>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn connection_properties(
listen_properties: &HttpListenProperties,
connection: &Self::Connection
) -> HttpConnectionProperties;
fn to_network_stream_from_connection(
connection: Self::Connection
) -> NetworkStream;
fn request_properties(
connection_properties: &HttpConnectionProperties,
uri: &Uri,
headers: &HeaderMap
) -> HttpRequestProperties;
}
Expand description
Pluggable trait to determine listen, connection and request properties for embedders that wish to provide alternative routes for incoming HTTP.
Required Associated Types§
type Listener: 'static
type Connection
Required Methods§
sourcefn get_listener_for_rid(
state: &mut OpState,
listener_rid: ResourceId
) -> Result<Self::Listener, AnyError>
fn get_listener_for_rid( state: &mut OpState, listener_rid: ResourceId ) -> Result<Self::Listener, AnyError>
Given a listener ResourceId
, returns the HttpPropertyExtractor::Listener
.
sourcefn get_connection_for_rid(
state: &mut OpState,
connection_rid: ResourceId
) -> Result<Self::Connection, AnyError>
fn get_connection_for_rid( state: &mut OpState, connection_rid: ResourceId ) -> Result<Self::Connection, AnyError>
Given a connection ResourceId
, returns the HttpPropertyExtractor::Connection
.
sourcefn listen_properties_from_listener(
listener: &Self::Listener
) -> Result<HttpListenProperties, Error>
fn listen_properties_from_listener( listener: &Self::Listener ) -> Result<HttpListenProperties, Error>
Determines the listener properties.
sourcefn listen_properties_from_connection(
connection: &Self::Connection
) -> Result<HttpListenProperties, Error>
fn listen_properties_from_connection( connection: &Self::Connection ) -> Result<HttpListenProperties, Error>
Determines the listener properties given a HttpPropertyExtractor::Connection
.
sourcefn accept_connection_from_listener<'life0, 'async_trait>(
listener: &'life0 Self::Listener
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, AnyError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn accept_connection_from_listener<'life0, 'async_trait>(
listener: &'life0 Self::Listener
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, AnyError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Accept a new HttpPropertyExtractor::Connection
from the given listener HttpPropertyExtractor::Listener
.
sourcefn connection_properties(
listen_properties: &HttpListenProperties,
connection: &Self::Connection
) -> HttpConnectionProperties
fn connection_properties( listen_properties: &HttpListenProperties, connection: &Self::Connection ) -> HttpConnectionProperties
Determines the connection properties.
sourcefn to_network_stream_from_connection(
connection: Self::Connection
) -> NetworkStream
fn to_network_stream_from_connection( connection: Self::Connection ) -> NetworkStream
Turn a given HttpPropertyExtractor::Connection
into a NetworkStream
.
sourcefn request_properties(
connection_properties: &HttpConnectionProperties,
uri: &Uri,
headers: &HeaderMap
) -> HttpRequestProperties
fn request_properties( connection_properties: &HttpConnectionProperties, uri: &Uri, headers: &HeaderMap ) -> HttpRequestProperties
Determines the request properties.
Object Safety§
This trait is not object safe.