Struct trillium_http::Upgrade
source · pub struct Upgrade<Transport> {
pub request_headers: Headers,
pub path: String,
pub method: Method,
pub state: StateSet,
pub transport: Transport,
pub buffer: Option<Vec<u8>>,
pub stopper: Stopper,
}
Expand description
This open (pub fields) 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.
Fields§
§request_headers: Headers
The http request headers
path: String
The request path
method: Method
The http request method
state: StateSet
Any state that has been accumulated on the Conn before negotiating the upgrade
transport: Transport
The underlying io (often a TcpStream
or similar)
buffer: Option<Vec<u8>>
Any bytes that have been read from the underlying tcpstream already. It is your responsibility to process these bytes before reading directly from the transport.
stopper: Stopper
A Stopper
which can and should be used to gracefully shut
down any long running streams or futures associated with this
upgrade
Implementations§
source§impl<Transport> Upgrade<Transport>
impl<Transport> Upgrade<Transport>
sourcepub fn headers(&self) -> &Headers
👎Deprecated: directly access the request_headers field
pub fn headers(&self) -> &Headers
see [request_headers
]
sourcepub fn querystring(&self) -> &str
pub fn querystring(&self) -> &str
retrieves the query component of the path
sourcepub fn state(&self) -> &StateSet
pub fn state(&self) -> &StateSet
any state that has been accumulated on the Conn before negotiating the upgrade.
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> !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