Skip to main content

Upgrade

Struct Upgrade 

Source
pub struct Upgrade<Transport> { /* private fields */ }
Expand description

This struct represents a http upgrade. It contains all of the data available on a Conn, as well as owning the underlying transport.

Important implementation note: When reading directly from the transport, ensure that you read from buffer first if there are bytes in it. Alternatively, read directly from the Upgrade, as that AsyncRead implementation will drain the buffer first before reading from the transport.

Implementations§

Source§

impl<Transport> Upgrade<Transport>

Source

pub fn request_headers(&self) -> &Headers

Borrows The http request headers

Source

pub fn request_headers_mut(&mut self) -> &mut Headers

Mutably borrow The http request headers

Source

pub fn set_request_headers(&mut self, request_headers: Headers) -> &mut Self

Sets The http request headers, returning &mut Self for chaining

Source

pub fn with_request_headers(self, request_headers: Headers) -> Self

Owned chainable setter for The http request headers, returning Self

Source

pub fn into_request_headers(self) -> Headers

Consumes self, returning The http request headers

Source

pub fn path_mut(&mut self) -> &mut Cow<'static, str>

Mutably borrow The request path

Source

pub fn set_path(&mut self, path: Cow<'static, str>) -> &mut Self

Sets The request path, returning &mut Self for chaining

Source

pub fn with_path(self, path: Cow<'static, str>) -> Self

Owned chainable setter for The request path, returning Self

Source

pub fn into_path(self) -> Cow<'static, str>

Consumes self, returning The request path

Source

pub fn method(&self) -> Method

Returns a copy of The http request method

Source

pub fn method_mut(&mut self) -> &mut Method

Mutably borrow The http request method

Source

pub fn set_method(&mut self, method: Method) -> &mut Self

Sets The http request method, returning &mut Self for chaining

Source

pub fn with_method(self, method: Method) -> Self

Owned chainable setter for The http request method, returning Self

Source

pub fn state(&self) -> &TypeSet

Borrows Any state that has been accumulated on the Conn before negotiating the upgrade

Source

pub fn state_mut(&mut self) -> &mut TypeSet

Mutably borrow Any state that has been accumulated on the Conn before negotiating the upgrade

Source

pub fn set_state(&mut self, state: TypeSet) -> &mut Self

Sets Any state that has been accumulated on the Conn before negotiating the upgrade, returning &mut Self for chaining

Source

pub fn with_state(self, state: TypeSet) -> Self

Owned chainable setter for Any state that has been accumulated on the Conn before negotiating the upgrade, returning Self

Source

pub fn into_state(self) -> TypeSet

Consumes self, returning Any state that has been accumulated on the Conn before negotiating the upgrade

Source

pub fn transport(&self) -> &Transport

Borrows The underlying io (often a TcpStream or similar)

Source

pub fn transport_mut(&mut self) -> &mut Transport

Mutably borrow The underlying io (often a TcpStream or similar)

Source

pub fn set_transport(&mut self, transport: Transport) -> &mut Self

Sets The underlying io (often a TcpStream or similar), returning &mut Self for chaining

Source

pub fn with_transport(self, transport: Transport) -> Self

Owned chainable setter for The underlying io (often a TcpStream or similar), returning Self

Source

pub fn into_transport(self) -> Transport

Consumes self, returning The underlying io (often a TcpStream or similar)

Source

pub fn buffer(&self) -> &[u8]

Borrows Any bytes that have been read from the underlying transport already.

It is your responsibility to process these bytes before reading directly from the transport.

Source

pub fn buffer_mut(&mut self) -> &mut [u8]

Mutably borrow Any bytes that have been read from the underlying transport already.

It is your responsibility to process these bytes before reading directly from the transport.

Source

pub fn context(&self) -> &Arc<HttpContext>

Borrows The HttpContext shared for this server

Source

pub fn context_mut(&mut self) -> &mut Arc<HttpContext>

Mutably borrow The HttpContext shared for this server

Source

pub fn set_context(&mut self, context: Arc<HttpContext>) -> &mut Self

Sets The HttpContext shared for this server, returning &mut Self for chaining

Source

pub fn with_context(self, context: Arc<HttpContext>) -> Self

Owned chainable setter for The HttpContext shared for this server, returning Self

Source

pub fn into_context(self) -> Arc<HttpContext>

Consumes self, returning The HttpContext shared for this server

Source

pub fn peer_ip(&self) -> Option<IpAddr>

Returns a copy of the ip address of the connection, if available

Source

pub fn peer_ip_mut(&mut self) -> Option<&mut IpAddr>

Mutably borrow the ip address of the connection, if available

Source

pub fn set_peer_ip(&mut self, peer_ip: Option<IpAddr>) -> &mut Self

Sets the ip address of the connection, if available, returning &mut Self for chaining

Source

pub fn with_peer_ip(self, peer_ip: Option<IpAddr>) -> Self

Owned chainable setter for the ip address of the connection, if available, returning Self

Source

pub fn take_peer_ip(&mut self) -> Option<IpAddr>

Takes the ip address of the connection, if available, leaving a None in its place

Source

pub fn authority(&self) -> Option<&str>

Borrows the :authority http/3 pseudo-header

Source

pub fn authority_mut(&mut self) -> Option<&mut Cow<'static, str>>

Mutably borrow the :authority http/3 pseudo-header

Source

pub fn set_authority( &mut self, authority: Option<Cow<'static, str>>, ) -> &mut Self

Sets the :authority http/3 pseudo-header, returning &mut Self for chaining

Source

pub fn with_authority(self, authority: Option<Cow<'static, str>>) -> Self

Owned chainable setter for the :authority http/3 pseudo-header, returning Self

Source

pub fn take_authority(&mut self) -> Option<Cow<'static, str>>

Takes the :authority http/3 pseudo-header, leaving a None in its place

Source

pub fn into_authority(self) -> Option<Cow<'static, str>>

Consumes self, returning the :authority http/3 pseudo-header

Source

pub fn scheme(&self) -> Option<&str>

Borrows the :scheme http/3 pseudo-header

Source

pub fn scheme_mut(&mut self) -> Option<&mut Cow<'static, str>>

Mutably borrow the :scheme http/3 pseudo-header

Source

pub fn set_scheme(&mut self, scheme: Option<Cow<'static, str>>) -> &mut Self

Sets the :scheme http/3 pseudo-header, returning &mut Self for chaining

Source

pub fn with_scheme(self, scheme: Option<Cow<'static, str>>) -> Self

Owned chainable setter for the :scheme http/3 pseudo-header, returning Self

Source

pub fn take_scheme(&mut self) -> Option<Cow<'static, str>>

Takes the :scheme http/3 pseudo-header, leaving a None in its place

Source

pub fn into_scheme(self) -> Option<Cow<'static, str>>

Consumes self, returning the :scheme http/3 pseudo-header

Source

pub fn h3_connection(&self) -> Option<&Arc<H3Connection>>

Borrows the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection

Source

pub fn h3_connection_mut(&mut self) -> Option<&mut Arc<H3Connection>>

Mutably borrow the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection

Source

pub fn set_h3_connection( &mut self, h3_connection: Option<Arc<H3Connection>>, ) -> &mut Self

Sets the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection, returning &mut Self for chaining

Source

pub fn with_h3_connection( self, h3_connection: Option<Arc<H3Connection>>, ) -> Self

Owned chainable setter for the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection, returning Self

Source

pub fn take_h3_connection(&mut self) -> Option<Arc<H3Connection>>

Takes the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection, leaving a None in its place

Source

pub fn into_h3_connection(self) -> Option<Arc<H3Connection>>

Consumes self, returning the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection

Source

pub fn protocol(&self) -> Option<&str>

Borrows the :protocol http/3 pseudo-header

Source

pub fn protocol_mut(&mut self) -> Option<&mut Cow<'static, str>>

Mutably borrow the :protocol http/3 pseudo-header

Source

pub fn set_protocol(&mut self, protocol: Option<Cow<'static, str>>) -> &mut Self

Sets the :protocol http/3 pseudo-header, returning &mut Self for chaining

Source

pub fn with_protocol(self, protocol: Option<Cow<'static, str>>) -> Self

Owned chainable setter for the :protocol http/3 pseudo-header, returning Self

Source

pub fn take_protocol(&mut self) -> Option<Cow<'static, str>>

Takes the :protocol http/3 pseudo-header, leaving a None in its place

Source

pub fn into_protocol(self) -> Option<Cow<'static, str>>

Consumes self, returning the :protocol http/3 pseudo-header

Source

pub fn http_version(&self) -> &Version

Borrows the http version

Source

pub fn http_version_mut(&mut self) -> &mut Version

Mutably borrow the http version

Source

pub fn set_http_version(&mut self, http_version: Version) -> &mut Self

Sets the http version, returning &mut Self for chaining

Source

pub fn with_http_version(self, http_version: Version) -> Self

Owned chainable setter for the http version, returning Self

Source

pub fn into_http_version(self) -> Version

Consumes self, returning the http version

Source

pub fn is_secure(&self) -> bool

Returns a copy of whether this connection was deemed secure by the handler stack

Source

pub fn secure_mut(&mut self) -> &mut bool

Mutably borrow whether this connection was deemed secure by the handler stack

Source

pub fn set_secure(&mut self, secure: bool) -> &mut Self

Sets whether this connection was deemed secure by the handler stack, returning &mut Self for chaining

Source

pub fn with_secure(self, secure: bool) -> Self

Owned chainable setter for whether this connection was deemed secure by the handler stack, returning Self

Source§

impl<Transport> Upgrade<Transport>

Source

pub fn take_buffer(&mut self) -> Vec<u8>

Take any buffered bytes

Source

pub fn shared_state(&self) -> &TypeSet

borrow the shared state TypeSet for this application

Source

pub fn path(&self) -> &str

the http request path up to but excluding any query component

Source

pub fn querystring(&self) -> &str

retrieves the query component of the path

Source

pub fn map_transport<T: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static>( self, f: impl Fn(Transport) -> T, ) -> Upgrade<T>

Modify the transport type of this upgrade.

This is useful for boxing the transport in order to erase the type argument.

Trait Implementations§

Source§

impl<Transport: AsyncRead + Unpin> AsyncRead for Upgrade<Transport>

Source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize>>

Attempt to read from the AsyncRead into buf. Read more
Source§

fn poll_read_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], ) -> Poll<Result<usize, Error>>

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
Source§

impl<Transport> AsyncWrite for Upgrade<Transport>
where Transport: AsyncWrite + Unpin, Self: Unpin,

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>

Attempt to write bytes from buf into the object. Read more
Source§

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

Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

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

Attempt to close the object. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize>>

Attempt to write bytes from bufs into the object using vectored IO operations. Read more
Source§

impl<Transport> Debug for Upgrade<Transport>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Transport> From<Conn<Transport>> for Upgrade<Transport>

Source§

fn from(conn: Conn<Transport>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Transport> Freeze for Upgrade<Transport>
where Transport: Freeze,

§

impl<Transport> !RefUnwindSafe for Upgrade<Transport>

§

impl<Transport> Send for Upgrade<Transport>
where Transport: Send,

§

impl<Transport> Sync for Upgrade<Transport>
where Transport: Sync,

§

impl<Transport> Unpin for Upgrade<Transport>
where Transport: Unpin,

§

impl<Transport> UnsafeUnpin for Upgrade<Transport>
where Transport: UnsafeUnpin,

§

impl<Transport> !UnwindSafe for Upgrade<Transport>

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<R> AsyncReadExt for R
where R: AsyncRead + ?Sized,

Source§

fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>
where Self: Unpin,

Reads some bytes from the byte stream. Read more
Source§

fn read_vectored<'a>( &'a mut self, bufs: &'a mut [IoSliceMut<'a>], ) -> ReadVectoredFuture<'a, Self>
where Self: Unpin,

Like read(), except it reads into a slice of buffers. Read more
Source§

fn read_to_end<'a>( &'a mut self, buf: &'a mut Vec<u8>, ) -> ReadToEndFuture<'a, Self>
where Self: Unpin,

Reads the entire contents and appends them to a Vec. Read more
Source§

fn read_to_string<'a>( &'a mut self, buf: &'a mut String, ) -> ReadToStringFuture<'a, Self>
where Self: Unpin,

Reads the entire contents and appends them to a String. Read more
Source§

fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>
where Self: Unpin,

Reads the exact number of bytes required to fill buf. Read more
Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Converts this AsyncRead into a Stream of bytes. Read more
Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: AsyncRead, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
Source§

fn boxed_reader<'a>(self) -> Pin<Box<dyn AsyncRead + Send + 'a>>
where Self: Sized + Send + 'a,

Boxes the reader and changes its type to dyn AsyncRead + Send + 'a. Read more
Source§

impl<W> AsyncWriteExt for W
where W: AsyncWrite + ?Sized,

Source§

fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>
where Self: Unpin,

Writes some bytes into the byte stream. Read more
Source§

fn write_vectored<'a>( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> WriteVectoredFuture<'a, Self>
where Self: Unpin,

Like write(), except that it writes a slice of buffers. Read more
Source§

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>
where Self: Unpin,

Writes an entire buffer into the byte stream. Read more
Source§

fn flush(&mut self) -> FlushFuture<'_, Self>
where Self: Unpin,

Flushes the stream to ensure that all buffered contents reach their destination. Read more
Source§

fn close(&mut self) -> CloseFuture<'_, Self>
where Self: Unpin,

Closes the writer. Read more
Source§

fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
where Self: Sized + Send + 'a,

Boxes the writer and changes its type to dyn AsyncWrite + Send + 'a. 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 = 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>,

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.