Enum trillium_smol::Binding
pub enum Binding<T, U> {
Tcp(T),
Unix(U),
}
Expand description
A wrapper enum that has blanket implementations for common traits like TryFrom, Stream, AsyncRead, and AsyncWrite. This can contain listeners (like TcpListener), Streams (like Incoming), or bytestreams (like TcpStream).
Variants§
Tcp(T)
a tcp type (listener or incoming or stream)
Unix(U)
a unix type (listener or incoming or stream)
Implementations§
§impl<T, U> Binding<T, U>
impl<T, U> Binding<T, U>
pub fn get_tcp_mut(&mut self) -> Option<&mut T>
pub fn get_tcp_mut(&mut self) -> Option<&mut T>
mutably borrows the tcp stream or listener, if this is tcp variant
pub fn get_unix_mut(&mut self) -> Option<&mut U>
pub fn get_unix_mut(&mut self) -> Option<&mut U>
mutably borrows the unix stream or listener, if this is unix variant
Trait Implementations§
§impl<T, U> AsyncRead for Binding<T, U>
impl<T, U> AsyncRead for Binding<T, U>
§impl<T, U> AsyncWrite for Binding<T, U>
impl<T, U> AsyncWrite for Binding<T, U>
§fn poll_write(
self: Pin<&mut Binding<T, U>>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Binding<T, U>>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from
buf
into the object. Read more§fn poll_flush(
self: Pin<&mut Binding<T, U>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Binding<T, U>>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
§impl<T, U, TI, UI> Stream for Binding<T, U>
impl<T, U, TI, UI> Stream for Binding<T, U>
§fn poll_next(
self: Pin<&mut Binding<T, U>>,
cx: &mut Context<'_>,
) -> Poll<Option<<Binding<T, U> as Stream>::Item>>
fn poll_next( self: Pin<&mut Binding<T, U>>, cx: &mut Context<'_>, ) -> Poll<Option<<Binding<T, U> as Stream>::Item>>
Attempt to pull out the next value of this stream, registering the
current task for wakeup if the value is not yet available, and returning
None
if the stream is exhausted. Read more§impl<T, U> Transport for Binding<T, U>
impl<T, U> Transport for Binding<T, U>
§fn set_linger(&mut self, linger: Option<Duration>) -> Result<(), Error>
fn set_linger(&mut self, linger: Option<Duration>) -> Result<(), Error>
Sets the linger duration of this transport by setting the
SO_LINGER
option Read more§fn set_nodelay(&mut self, nodelay: bool) -> Result<(), Error>
fn set_nodelay(&mut self, nodelay: bool) -> Result<(), Error>
Sets the value of the
TCP_NODELAY
option on this transport. Read more§impl<T, U> TryFrom<TcpListener> for Binding<T, U>where
T: TryFrom<TcpListener>,
impl<T, U> TryFrom<TcpListener> for Binding<T, U>where
T: TryFrom<TcpListener>,
§type Error = <T as TryFrom<TcpListener>>::Error
type Error = <T as TryFrom<TcpListener>>::Error
The type returned in the event of a conversion error.
§fn try_from(
value: TcpListener,
) -> Result<Binding<T, U>, <Binding<T, U> as TryFrom<TcpListener>>::Error>
fn try_from( value: TcpListener, ) -> Result<Binding<T, U>, <Binding<T, U> as TryFrom<TcpListener>>::Error>
Performs the conversion.
§impl<T, U> TryFrom<UnixListener> for Binding<T, U>where
U: TryFrom<UnixListener>,
impl<T, U> TryFrom<UnixListener> for Binding<T, U>where
U: TryFrom<UnixListener>,
§type Error = <U as TryFrom<UnixListener>>::Error
type Error = <U as TryFrom<UnixListener>>::Error
The type returned in the event of a conversion error.
§fn try_from(
value: UnixListener,
) -> Result<Binding<T, U>, <Binding<T, U> as TryFrom<UnixListener>>::Error>
fn try_from( value: UnixListener, ) -> Result<Binding<T, U>, <Binding<T, U> as TryFrom<UnixListener>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl<T, U> Freeze for Binding<T, U>
impl<T, U> RefUnwindSafe for Binding<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Binding<T, U>
impl<T, U> Sync for Binding<T, U>
impl<T, U> Unpin for Binding<T, U>
impl<T, U> UnwindSafe for Binding<T, U>where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations§
§impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
§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,
Reads some bytes from the byte stream. Read more
§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,
§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,
§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,
§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,
Reads the exact number of bytes required to fill
buf
. Read more§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
Creates an adapter which will read at most
limit
bytes from it. Read more§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
§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,
Writes some bytes into the byte stream. Read more
§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,
§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,
Writes an entire buffer into the byte stream. Read more
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<S> StreamExt for Swhere
S: Stream + ?Sized,
impl<S> StreamExt for Swhere
S: Stream + ?Sized,
§fn next(&mut self) -> NextFuture<'_, Self>where
Self: Unpin,
fn next(&mut self) -> NextFuture<'_, Self>where
Self: Unpin,
Retrieves the next item in the stream. Read more
§fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>
fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>
Retrieves the next item in the stream. Read more
§fn count(self) -> CountFuture<Self>where
Self: Sized,
fn count(self) -> CountFuture<Self>where
Self: Sized,
Counts the number of items in the stream. Read more
§fn map<T, F>(self, f: F) -> Map<Self, F>
fn map<T, F>(self, f: F) -> Map<Self, F>
Maps items of the stream to new values using a closure. Read more
§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
Maps items to streams and then concatenates them. Read more
§fn flatten(self) -> Flatten<Self>where
Self: Sized,
Self::Item: Stream,
fn flatten(self) -> Flatten<Self>where
Self: Sized,
Self::Item: Stream,
Concatenates inner streams. Read more
§fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>
fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut>
Maps items of the stream to new values using an async closure. Read more
§fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
Filters and maps items of the stream using a closure. Read more
§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
Takes only the first
n
items of the stream. Read more§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
Skips the first
n
items of the stream. Read more§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
§fn chain<U>(self, other: U) -> Chain<Self, U>where
Self: Sized,
U: Stream<Item = Self::Item>,
fn chain<U>(self, other: U) -> Chain<Self, U>where
Self: Sized,
U: Stream<Item = Self::Item>,
Appends another stream to the end of this one. Read more
§fn collect<C>(self) -> CollectFuture<Self, C>
fn collect<C>(self) -> CollectFuture<Self, C>
Collects all items in the stream into a collection. Read more
§fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>
fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>
Collects all items in the fallible stream into a collection. Read more
§fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>
fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>
Partitions items into those for which
predicate
is true
and those for which it is
false
, and then collects them into two collections. Read more§fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>
fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>
Accumulates a computation over the stream. Read more
§fn try_fold<T, E, F, B>(
&mut self,
init: B,
f: F,
) -> TryFoldFuture<'_, Self, F, B>
fn try_fold<T, E, F, B>( &mut self, init: B, f: F, ) -> TryFoldFuture<'_, Self, F, B>
Accumulates a fallible computation over the stream. Read more
§fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
Maps items of the stream to new values using a state value and a closure. Read more
§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Enumerates items, mapping them to
(index, item)
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Calls a closure on each item and passes it on. Read more
§fn nth(&mut self, n: usize) -> NthFuture<'_, Self>where
Self: Unpin,
fn nth(&mut self, n: usize) -> NthFuture<'_, Self>where
Self: Unpin,
Gets the
n
th item of the stream. Read more§fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>
fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>
Calls a closure on each item of the stream. Read more
§fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>
fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>
Calls a fallible closure on each item of the stream, stopping on first error. Read more
§fn zip<U>(self, other: U) -> Zip<Self, U>where
Self: Sized,
U: Stream,
fn zip<U>(self, other: U) -> Zip<Self, U>where
Self: Sized,
U: Stream,
Zips up two streams into a single stream of pairs. Read more
§fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>
fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>
Collects a stream of pairs into a pair of collections. Read more
§fn race<S>(self, other: S) -> Race<Self, S>where
Self: Sized,
S: Stream<Item = Self::Item>,
fn race<S>(self, other: S) -> Race<Self, S>where
Self: Sized,
S: Stream<Item = Self::Item>,
Merges with
other
stream, with no preference for either stream when both are ready. Read more§fn drain(&mut self) -> Drain<'_, Self>
fn drain(&mut self) -> Drain<'_, Self>
Yields all immediately available values from a stream. Read more