Struct mio_httpc::Httpc

source ·
pub struct Httpc { /* private fields */ }

Implementations§

source§

impl Httpc

source

pub fn new(con_offset: usize, cfg: Option<HttpcCfg>) -> Httpc

Httpc will create connections with mio token in range [con_offset..con_offset+0xFFFF]

source

pub fn cfg_mut(&mut self) -> &mut HttpcCfg

Reconfigure httpc.

source

pub fn open_connections(&self) -> usize

Number of currently open connections (in active and idle keep-alive state)

source

pub fn reuse(&mut self, buf: Vec<u8>)

Reuse a response buffer for subsequent calls.

source

pub fn call_close(&mut self, id: Call)

Prematurely finish call.

source

pub fn timeout(&mut self) -> Vec<CallRef>

Call periodically to check for call timeouts and DNS retries. Returns list of calls that have timed out. You must execute call_close yourself (or SimpleCall::abort) and timeout will return them every time until you do. (every 100ms for example)

source

pub fn timeout_extend<C: TlsConnector>(&mut self, out: &mut Vec<CallRef>)

Same as timeout except that timed out calls get appended. This way you can reuse old allocations (if you truncated to 0).

source

pub fn event(&mut self, ev: &Event) -> Option<CallRef>

Get CallRef for ev if token in configured range for Httpc. Compare CallRef with external Call to find out which call this event belongs to if any.

This call is mandatory as it sets up internal data structures for when something is signalled! Even if you know which call is being signalled, you must call event to let mio_httpc know what state socket is in.

For streaming API first you must call call_send until you get a SendState::Receiving after that call is in receive state and you must call call_recv.

source

pub fn call_send( &mut self, poll: &Registry, id: &mut Call, buf: Option<&[u8]> ) -> SendState

If request has body it will be either taken from buf, from Request provided to CallBuilder or will return SendState::WaitReqBody.

buf slice is assumed to have taken previous SendState::SentBody(usize) into account and starts from part of buffer that has not been sent yet.

source

pub fn call_recv( &mut self, poll: &Registry, id: &mut Call, buf: Option<&mut Vec<u8>> ) -> RecvState

If no buf provided, response body (if any) is stored in an internal buffer. If buf provided after some body has been received, it will be copied to it.

Buf will be expanded if required. Bytes are always appended. If you want to receive response entirely in buf, you should reserve capacity for entire body before calling call_recv.

If body is only stored in internal buffer it will be limited to CallBuilder::max_response.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Httpc

§

impl Send for Httpc

§

impl Sync for Httpc

§

impl Unpin for Httpc

§

impl !UnwindSafe for Httpc

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V