Skip to main content

Event

Enum Event 

Source
pub enum Event<'a> {
    Head(Head),
    Informational(Head),
    Body(&'a [u8]),
    Trailers(Vec<Header>),
    End,
    Upgrade,
}

Variants§

§

Head(Head)

§

Informational(Head)

§

Body(&'a [u8])

§

Trailers(Vec<Header>)

§

End

The message is complete. Reads no input: see Step.

§

Upgrade

The message is complete, and it leaves HTTP/1 or asks to. Raised instead of Event::End, with consumed == 0, as the last event of the message. Every byte after it belongs to the next protocol, so the host takes its retained input along.

Both Modes raise it:

  • Mode::Response: a 101 Switching Protocols, or a 2xx answer to a request passed to Decoder::response_to as CONNECT. The switch has happened, so the decoder is never reusable afterwards.
  • Mode::Request: an HTTP/1.1 request with an Upgrade header and the upgrade token in Connection (RFC 9110 section 7.8), or any CONNECT request. It follows the request body, if there is one. The switch has not happened: answering 101 (or 2xx for CONNECT) is the host’s decision. A host that accepts stops feeding this decoder. A host that declines sends an ordinary response and may carry on: the decoder is reusable on the same terms as after Event::End, and Decoder::reset resumes HTTP/1.

An Upgrade header on an HTTP/1.0 request is ignored, as RFC 9110 section 7.8 requires, and that request ends with Event::End.

Trait Implementations§

Source§

impl<'a> Debug for Event<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Forget for Event<'a>

§

impl<'a> Freeze for Event<'a>

§

impl<'a> RefUnwindSafe for Event<'a>

§

impl<'a> Send for Event<'a>

§

impl<'a> Sync for Event<'a>

§

impl<'a> Unpin for Event<'a>

§

impl<'a> UnsafeUnpin for Event<'a>

§

impl<'a> UnwindSafe for Event<'a>

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.