Struct trillium_http::transport::BoxedTransport [−][src]
pub struct BoxedTransport(_);
Expand description
A type for dyn Transport
trait objects
BoxedTransport represents a Box<dyn Transport>
that supports
downcasting to the original Transport. This is used in trillium to
erase the generic on Conn, in order to avoid writing Conn<TcpStream>
throughout an application.
Stability Note: This may go away at some point and be
replaced by a type alias exported from a
trillium_server_common::Server
crate.
Implementations
Create a new BoxedTransport from some Transport.
use trillium_http::transport::BoxedTransport;
use trillium_testing::TestTransport;
// this examples uses trillium_testing::TestTransport as an
// easily-constructed AsyncRead+AsyncWrite.
let (test_transport, _) = TestTransport::new();
let boxed = BoxedTransport::new(test_transport);
let downcast: Option<Box<TestTransport>> = boxed.downcast();
assert!(downcast.is_some());
let boxed_again = BoxedTransport::new(*downcast.unwrap());
assert!(boxed_again.downcast::<async_net::TcpStream>().is_none());
Attempt to convert the trait object into a specific transport
T. This will only succeed if T is the type that was originally
passed to BoxedTransport::new
, and will return None otherwise
see BoxedTransport::new for example usage
Methods from Deref<Target = Box<dyn Transport + Send + Sync + 'static>>
Trait Implementations
Attempt to read from the AsyncRead
into buf
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for BoxedTransport
impl Send for BoxedTransport
impl Sync for BoxedTransport
impl Unpin for BoxedTransport
impl !UnwindSafe for BoxedTransport
Blanket Implementations
Reads some bytes from the byte stream. Read more
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
Reads the exact number of bytes required to fill buf
. Read more
Creates an adapter which will read at most limit
bytes from it. Read more
Creates an adapter which will chain this stream with another. Read more
Writes some bytes into the byte stream. Read more
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self> where
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self> where
Self: Unpin,
Writes an entire buffer into the byte stream. Read more
Flushes the stream to ensure that all buffered contents reach their destination. Read more
Closes the writer. Read more
Mutably borrows from an owned value. Read more