Struct SendRequest

pub struct SendRequest<B> { /* private fields */ }

The sender side of an established connection.

Implementations

impl<B> SendRequest<B>

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>

Polls to determine whether this sender can be used yet for a request.

If the associated connection is closed, this returns an Error.

async fn ready(&mut self) -> Result<()>

Waits until the dispatcher is ready.

If the associated connection is closed, this returns an Error.

fn is_ready(&self) -> bool

Checks if the connection is currently ready to send a request.

Note

This is mostly a hint. Due to inherent latency of networks, it is possible that even after checking this is ready, sending a request may still fail because the connection was closed in the meantime.

fn is_closed(&self) -> bool

Checks if the connection side has been closed.

impl<B> SendRequest<B> where B: Body + 'static,

fn send_request(&mut self, req: Request<B>) -> impl Future<Output = Result<Response<IncomingBody>>>

Sends a Request on the associated connection.

Returns a future that if successful, yields the Response.

req must have a Host header.

Uri

The Uri of the request is serialized as-is.

  • Usually you want origin-form (/path?query).
  • For sending to an HTTP proxy, you want to send in absolute-form (https://hyper.rs/guides).

This is however not enforced or validated and it is up to the user of this method to ensure the Uri is correct for their intended purpose.

Cancel safety

Dropping the returned future is the supported way to cancel an in-flight HTTP/1 request. Because HTTP/1 has no in-protocol way to abort a single request without affecting the shared connection, hyper closes the underlying connection when a request future is dropped before completion. Any subsequent calls on the same SendRequest will return a canceled error.

fn try_send_request(&mut self, req: Request<B>) -> impl Future<Output = Result<Response<IncomingBody>, TrySendError<Request<B>>>>

Sends a Request on the associated connection.

Returns a future that if successful, yields the Response.

Error

If there was an error before trying to serialize the request to the connection, the message will be returned as part of this error.

Trait Implementations

impl<B> Debug for SendRequest<B>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<B> !RefUnwindSafe for SendRequest<B>

impl<B> !UnwindSafe for SendRequest<B>

impl<B> Freeze for SendRequest<B> where Sender<Request<B>, Response<Incoming>>: Freeze,

impl<B> Send for SendRequest<B> where Sender<Request<B>, Response<Incoming>>: Send,

impl<B> Sync for SendRequest<B> where Sender<Request<B>, Response<Incoming>>: Sync,

impl<B> Unpin for SendRequest<B> where Sender<Request<B>, Response<Incoming>>: Unpin,

impl<B> UnsafeUnpin for SendRequest<B> where Sender<Request<B>, Response<Incoming>>: UnsafeUnpin,

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for SendRequest<B>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for SendRequest<B>

impl<T> WithSubscriber for SendRequest<B>

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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