Trait rotor_http::client::Client
[−]
[src]
pub trait Client: Sized { type Requester: Requester; type Seed: Clone + Sized; fn create(
seed: Self::Seed,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Self; fn connection_idle(
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>; fn connection_error(
self,
reason: &ProtocolError,
scope: &mut Scope<<Self::Requester as Requester>::Context>
); fn wakeup(
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>; fn timeout(
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>; fn connect_timeout(
&self,
_scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Duration { ... } fn idle_timeout(
&self,
_scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Duration { ... } }
A state machine that allows to initiate a client-side HTTP request
Used for all versions of HTTP.
Associated Types
Required Methods
fn create(
seed: Self::Seed,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Self
seed: Self::Seed,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Self
fn connection_idle(
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>
The handler is invoked when connection is succeed or when previous request has just finished
To initiate a request, return Requester
as part of a return value.
fn connection_error(
self,
reason: &ProtocolError,
scope: &mut Scope<<Self::Requester as Requester>::Context>
)
self,
reason: &ProtocolError,
scope: &mut Scope<<Self::Requester as Requester>::Context>
)
Error when establishing connection or connection closed when in idle
fn wakeup(
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>
Standard rotor's wakeup handler
If connection.is_idle()
you may initiate a new request
Note: currently we call this action only when there is no request beign active (otherwise wakeup goes to request state machine), but we may change it in future to allow request pipelining
fn timeout(
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>
self,
connection: &Connection,
scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Task<Self>
Standard rotor's timeout handler
If connection.is_idle()
you may initiate a new request
Note: currently we call this action only when there is no request beign active (otherwise timeout goes to request state machine), but we may change it in future to allow request pipelining
Provided Methods
fn connect_timeout(
&self,
_scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Duration
&self,
_scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Duration
Returns number of seconds to wait for connection to be established
This timeout is not obeyed for Persistent
connections
fn idle_timeout(
&self,
_scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Duration
&self,
_scope: &mut Scope<<Self::Requester as Requester>::Context>
) -> Duration
Idle timeout
Timeout for keep-alive connection to be idle