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>
impl<Transport> Upgrade<Transport>
Sourcepub fn request_headers(&self) -> &Headers
pub fn request_headers(&self) -> &Headers
Borrows The http request headers
Sourcepub fn request_headers_mut(&mut self) -> &mut Headers
pub fn request_headers_mut(&mut self) -> &mut Headers
Mutably borrow The http request headers
Sourcepub fn set_request_headers(&mut self, request_headers: Headers) -> &mut Self
pub fn set_request_headers(&mut self, request_headers: Headers) -> &mut Self
Sets The http request headers, returning &mut Self for chaining
Sourcepub fn with_request_headers(self, request_headers: Headers) -> Self
pub fn with_request_headers(self, request_headers: Headers) -> Self
Owned chainable setter for The http request headers, returning Self
Sourcepub fn into_request_headers(self) -> Headers
pub fn into_request_headers(self) -> Headers
Consumes self, returning The http request headers
Sourcepub fn set_path(&mut self, path: Cow<'static, str>) -> &mut Self
pub fn set_path(&mut self, path: Cow<'static, str>) -> &mut Self
Sets The request path, returning &mut Self for chaining
Sourcepub fn with_path(self, path: Cow<'static, str>) -> Self
pub fn with_path(self, path: Cow<'static, str>) -> Self
Owned chainable setter for The request path, returning Self
Sourcepub fn method_mut(&mut self) -> &mut Method
pub fn method_mut(&mut self) -> &mut Method
Mutably borrow The http request method
Sourcepub fn set_method(&mut self, method: Method) -> &mut Self
pub fn set_method(&mut self, method: Method) -> &mut Self
Sets The http request method, returning &mut Self for chaining
Sourcepub fn with_method(self, method: Method) -> Self
pub fn with_method(self, method: Method) -> Self
Owned chainable setter for The http request method, returning Self
Sourcepub fn state(&self) -> &TypeSet
pub fn state(&self) -> &TypeSet
Borrows Any state that has been accumulated on the Conn before negotiating the upgrade
Sourcepub fn state_mut(&mut self) -> &mut TypeSet
pub fn state_mut(&mut self) -> &mut TypeSet
Mutably borrow Any state that has been accumulated on the Conn before negotiating the upgrade
Sourcepub fn set_state(&mut self, state: TypeSet) -> &mut Self
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
Sourcepub fn with_state(self, state: TypeSet) -> Self
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
Sourcepub fn into_state(self) -> TypeSet
pub fn into_state(self) -> TypeSet
Consumes self, returning Any state that has been accumulated on the Conn before negotiating the upgrade
Sourcepub fn transport(&self) -> &Transport
pub fn transport(&self) -> &Transport
Borrows The underlying io (often a TcpStream or similar)
Sourcepub fn transport_mut(&mut self) -> &mut Transport
pub fn transport_mut(&mut self) -> &mut Transport
Mutably borrow The underlying io (often a TcpStream or similar)
Sourcepub fn set_transport(&mut self, transport: Transport) -> &mut Self
pub fn set_transport(&mut self, transport: Transport) -> &mut Self
Sets The underlying io (often a TcpStream or similar), returning &mut Self for chaining
Sourcepub fn with_transport(self, transport: Transport) -> Self
pub fn with_transport(self, transport: Transport) -> Self
Owned chainable setter for The underlying io (often a TcpStream or similar), returning Self
Sourcepub fn into_transport(self) -> Transport
pub fn into_transport(self) -> Transport
Consumes self, returning The underlying io (often a TcpStream or similar)
Sourcepub fn buffer(&self) -> &[u8] ⓘ
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.
Sourcepub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
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.
Sourcepub fn context(&self) -> &Arc<HttpContext>
pub fn context(&self) -> &Arc<HttpContext>
Borrows The HttpContext shared for this server
Sourcepub fn context_mut(&mut self) -> &mut Arc<HttpContext>
pub fn context_mut(&mut self) -> &mut Arc<HttpContext>
Mutably borrow The HttpContext shared for this server
Sourcepub fn set_context(&mut self, context: Arc<HttpContext>) -> &mut Self
pub fn set_context(&mut self, context: Arc<HttpContext>) -> &mut Self
Sets The HttpContext shared for this server, returning &mut Self for chaining
Sourcepub fn with_context(self, context: Arc<HttpContext>) -> Self
pub fn with_context(self, context: Arc<HttpContext>) -> Self
Owned chainable setter for The HttpContext shared for this server, returning Self
Sourcepub fn into_context(self) -> Arc<HttpContext>
pub fn into_context(self) -> Arc<HttpContext>
Consumes self, returning The HttpContext shared for this server
Sourcepub fn peer_ip(&self) -> Option<IpAddr>
pub fn peer_ip(&self) -> Option<IpAddr>
Returns a copy of the ip address of the connection, if available
Sourcepub fn peer_ip_mut(&mut self) -> Option<&mut IpAddr>
pub fn peer_ip_mut(&mut self) -> Option<&mut IpAddr>
Mutably borrow the ip address of the connection, if available
Sourcepub fn set_peer_ip(&mut self, peer_ip: Option<IpAddr>) -> &mut Self
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
Sourcepub fn with_peer_ip(self, peer_ip: Option<IpAddr>) -> Self
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
Sourcepub fn take_peer_ip(&mut self) -> Option<IpAddr>
pub fn take_peer_ip(&mut self) -> Option<IpAddr>
Takes the ip address of the connection, if available, leaving a None in its place
Borrows the :authority http/3 pseudo-header
Mutably borrow the :authority http/3 pseudo-header
Sets the :authority http/3 pseudo-header, returning &mut Self for chaining
Owned chainable setter for the :authority http/3 pseudo-header, returning Self
Takes the :authority http/3 pseudo-header, leaving a None in its place
Consumes self, returning the :authority http/3 pseudo-header
Sourcepub fn scheme_mut(&mut self) -> Option<&mut Cow<'static, str>>
pub fn scheme_mut(&mut self) -> Option<&mut Cow<'static, str>>
Mutably borrow the :scheme http/3 pseudo-header
Sourcepub fn set_scheme(&mut self, scheme: Option<Cow<'static, str>>) -> &mut Self
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
Sourcepub fn with_scheme(self, scheme: Option<Cow<'static, str>>) -> Self
pub fn with_scheme(self, scheme: Option<Cow<'static, str>>) -> Self
Owned chainable setter for the :scheme http/3 pseudo-header, returning Self
Sourcepub fn take_scheme(&mut self) -> Option<Cow<'static, str>>
pub fn take_scheme(&mut self) -> Option<Cow<'static, str>>
Takes the :scheme http/3 pseudo-header, leaving a None in its place
Sourcepub fn into_scheme(self) -> Option<Cow<'static, str>>
pub fn into_scheme(self) -> Option<Cow<'static, str>>
Consumes self, returning the :scheme http/3 pseudo-header
Sourcepub fn h3_connection(&self) -> Option<&Arc<H3Connection>>
pub fn h3_connection(&self) -> Option<&Arc<H3Connection>>
Borrows the HTTP/3 connection associated with this upgrade, if this was an HTTP/3 connection
Sourcepub fn h3_connection_mut(&mut self) -> Option<&mut Arc<H3Connection>>
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
Sourcepub fn set_h3_connection(
&mut self,
h3_connection: Option<Arc<H3Connection>>,
) -> &mut Self
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
Sourcepub fn with_h3_connection(
self,
h3_connection: Option<Arc<H3Connection>>,
) -> Self
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
Sourcepub fn take_h3_connection(&mut self) -> Option<Arc<H3Connection>>
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
Sourcepub fn into_h3_connection(self) -> Option<Arc<H3Connection>>
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
Sourcepub fn protocol_mut(&mut self) -> Option<&mut Cow<'static, str>>
pub fn protocol_mut(&mut self) -> Option<&mut Cow<'static, str>>
Mutably borrow the :protocol http/3 pseudo-header
Sourcepub fn set_protocol(&mut self, protocol: Option<Cow<'static, str>>) -> &mut Self
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
Sourcepub fn with_protocol(self, protocol: Option<Cow<'static, str>>) -> Self
pub fn with_protocol(self, protocol: Option<Cow<'static, str>>) -> Self
Owned chainable setter for the :protocol http/3 pseudo-header, returning Self
Sourcepub fn take_protocol(&mut self) -> Option<Cow<'static, str>>
pub fn take_protocol(&mut self) -> Option<Cow<'static, str>>
Takes the :protocol http/3 pseudo-header, leaving a None in its place
Sourcepub fn into_protocol(self) -> Option<Cow<'static, str>>
pub fn into_protocol(self) -> Option<Cow<'static, str>>
Consumes self, returning the :protocol http/3 pseudo-header
Sourcepub fn http_version(&self) -> &Version
pub fn http_version(&self) -> &Version
Borrows the http version
Sourcepub fn http_version_mut(&mut self) -> &mut Version
pub fn http_version_mut(&mut self) -> &mut Version
Mutably borrow the http version
Sourcepub fn set_http_version(&mut self, http_version: Version) -> &mut Self
pub fn set_http_version(&mut self, http_version: Version) -> &mut Self
Sets the http version, returning &mut Self for chaining
Sourcepub fn with_http_version(self, http_version: Version) -> Self
pub fn with_http_version(self, http_version: Version) -> Self
Owned chainable setter for the http version, returning Self
Sourcepub fn into_http_version(self) -> Version
pub fn into_http_version(self) -> Version
Consumes self, returning the http version
Sourcepub fn is_secure(&self) -> bool
pub fn is_secure(&self) -> bool
Returns a copy of whether this connection was deemed secure by the handler stack
Sourcepub fn secure_mut(&mut self) -> &mut bool
pub fn secure_mut(&mut self) -> &mut bool
Mutably borrow whether this connection was deemed secure by the handler stack
Sourcepub fn set_secure(&mut self, secure: bool) -> &mut Self
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
Sourcepub fn with_secure(self, secure: bool) -> Self
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>
impl<Transport> Upgrade<Transport>
Sourcepub fn take_buffer(&mut self) -> Vec<u8> ⓘ
pub fn take_buffer(&mut self) -> Vec<u8> ⓘ
Take any buffered bytes
borrow the shared state TypeSet for this application
Sourcepub fn querystring(&self) -> &str
pub fn querystring(&self) -> &str
retrieves the query component of the path
Sourcepub fn map_transport<T: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static>(
self,
f: impl Fn(Transport) -> T,
) -> Upgrade<T>
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>
impl<Transport: AsyncRead + Unpin> AsyncRead for Upgrade<Transport>
Source§impl<Transport> AsyncWrite for Upgrade<Transport>
impl<Transport> AsyncWrite for Upgrade<Transport>
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
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<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
Source§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
buf. Read moreSource§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit bytes from it. Read moreSource§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>where
Self: Unpin,
Source§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>where
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>where
Self: Unpin,
Source§fn flush(&mut self) -> FlushFuture<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> FlushFuture<'_, Self>where
Self: Unpin,
Source§fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
dyn AsyncWrite + Send + 'a. Read more