Enum spirit_tokio::either::Either [−][src]
The Either
type allows to wrap two similar Fragment
s and let the user choose
which one will be used.
For example, if your server could run both on common TCP and unix domain stream sockets, you
could use the Either<TcpListen, UnixListen>
. This fragment would then create resources of
type Either<TcpListener, UnixListener>
.
Many traits are delegated through to one or the other instance inside (in case both implement
it). So, the above resource will implement the Accept
trait that will accept
instances of Either<TcpStream, UnixStream>
. These’ll in turn implement AsyncRead
and
AsyncWrite
, therefore can be handled uniformly just as connections.
Deserialization
This uses the untagged serde attribute. This means there are no additional configuration
options present and the choice is made by trying to first deserialize the A
variant and
if that fails, trying the B
one. Therefore, the inner resource configs need to have some
distinct fields. In our example, this would parse as TcpListen
:
[[listen]]
port = 1234
While this as an UnixListen
:
[[listen]]
path = "/tmp/socket"
If you need different parsing, you can use either a newtype or remote derive.
Other similar types
This is not the only Either
type around. Unfortunately, none of the available ones was just
right for the use case here, so this crate rolls its own. But it provides From
/Into
conversions between them, if the corresponding feature on this crate is enabled.
More than two options
This allows only two variants. However, if you need more, it is possible to nest them and form a tree.
Drawbacks
Due to the complexity of implementation, the Fragment
is implemented for either only if
both variants are Fragment
s with simple enough Driver
s (drivers that don’t sub-divide
their Fragment
s). Therefore, Vec<Either<TcpListen, UnixListen>>
will work, but
Either<Vec<TcpListen>, Vec<UnixListen>>
will not.
This is an implementation limitation and may be lifted in the future (PRs are welcome).
Examples
use std::sync::Arc; use serde::Deserialize; use spirit::{AnyError, Empty, Pipeline, Spirit}; use spirit::prelude::*; #[cfg(unix)] use spirit_tokio::either::Either; use spirit_tokio::handlers::PerConnection; use spirit_tokio::net::TcpListen; #[cfg(unix)] use spirit_tokio::net::unix::UnixListen; use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio::pin; // If we want to work on systems that don't have unix domain sockets... #[cfg(unix)] type Listener = Either<TcpListen, UnixListen>; #[cfg(not(unix))] type Listener = TcpListen; const DEFAULT_CONFIG: &str = r#" [[listening_socket]] port = 1235 max-conn = 20 error-sleep = "100ms" "#; #[derive(Default, Deserialize)] struct Config { listening_socket: Vec<Listener>, } impl Config { fn listen(&self) -> Vec<Listener> { self.listening_socket.clone() } } async fn handle_connection<C: AsyncWrite>(conn: C) -> Result<(), AnyError> { pin!(conn); conn.write_all(b"hello world").await?; conn.shutdown().await?; Ok(()) } fn main() { let handler = PerConnection(|conn, _cfg: &_| async { if let Err(e) = handle_connection(conn).await { eprintln!("Error: {}", e); } }); Spirit::<Empty, Config>::new() .config_defaults(DEFAULT_CONFIG) .with(Pipeline::new("listen").extract_cfg(Config::listen).transform(handler)) .run(|spirit| { Ok(()) }); }
Variants
Implementations
impl<T> Either<T, T>
[src]
pub fn into_inner(self) -> T
[src]
Extracts the inner value in case both have the same type.
Sometimes, a series of operations produces an Either
with both types the same. In such
case, Either
plays no role anymore and this method can be used to get to the inner value.
Trait Implementations
impl<A, B> Accept for Either<A, B> where
A: Accept,
B: Accept,
[src]
A: Accept,
B: Accept,
type Connection = Either<A::Connection, B::Connection>
The type of the accepted connection.
fn poll_accept(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<Self::Connection, IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<Self::Connection, IoError>>
fn accept(self: Pin<&mut Self>) -> AcceptFuture<'_, Self>ⓘNotable traits for AcceptFuture<'_, A>
impl<A: Accept> Future for AcceptFuture<'_, A> type Output = Result<A::Connection, IoError>;
[src]
Notable traits for AcceptFuture<'_, A>
impl<A: Accept> Future for AcceptFuture<'_, A> type Output = Result<A::Connection, IoError>;
impl<A, B> AsyncBufRead for Either<A, B> where
A: AsyncBufRead,
B: AsyncBufRead,
[src]
A: AsyncBufRead,
B: AsyncBufRead,
fn poll_fill_buf(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<&[u8], IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<&[u8], IoError>>
fn consume(self: Pin<&mut Self>, amt: usize)
[src]
impl<A, B> AsyncRead for Either<A, B> where
A: AsyncRead,
B: AsyncRead,
[src]
A: AsyncRead,
B: AsyncRead,
fn poll_read(
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &mut ReadBuf<'_>
) -> Poll<Result<(), IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &mut ReadBuf<'_>
) -> Poll<Result<(), IoError>>
impl<A, B> AsyncSeek for Either<A, B> where
A: AsyncSeek,
B: AsyncSeek,
[src]
A: AsyncSeek,
B: AsyncSeek,
fn start_seek(self: Pin<&mut Self>, position: SeekFrom) -> Result<(), IoError>
[src]
fn poll_complete(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<u64, IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<u64, IoError>>
impl<A, B> AsyncWrite for Either<A, B> where
A: AsyncWrite,
B: AsyncWrite,
[src]
A: AsyncWrite,
B: AsyncWrite,
fn poll_write(
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, IoError>>
fn poll_flush(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<(), IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<(), IoError>>
fn poll_shutdown(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<(), IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Result<(), IoError>>
fn poll_write_vectored(
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, IoError>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, IoError>>
fn is_write_vectored(&self) -> bool
[src]
impl<A: Clone, B: Clone> Clone for Either<A, B>
[src]
impl<A, B, AR, BR> Comparable<Either<AR, BR>> for Either<A, B> where
A: Comparable<AR>,
B: Comparable<BR>,
[src]
A: Comparable<AR>,
B: Comparable<BR>,
fn compare(&self, rhs: &Either<AR, BR>) -> Comparison
[src]
impl<A: Copy, B: Copy> Copy for Either<A, B>
[src]
impl<A: Debug, B: Debug> Debug for Either<A, B>
[src]
impl<'de, A, B> Deserialize<'de> for Either<A, B> where
A: Deserialize<'de>,
B: Deserialize<'de>,
[src]
A: Deserialize<'de>,
B: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<A, B> Driver<Either<A, B>> for EitherDriver<A, B> where
A: Fragment,
A::Driver: Driver<A, SubFragment = A> + Default,
B: Fragment,
B::Driver: Driver<B, SubFragment = B> + Default,
[src]
A: Fragment,
A::Driver: Driver<A, SubFragment = A> + Default,
B: Fragment,
B::Driver: Driver<B, SubFragment = B> + Default,
type SubFragment = Either<A, B>
fn instructions<T, I>(
&mut self,
fragment: &Either<A, B>,
transform: &mut T,
name: &'static str
) -> Result<Vec<Instruction<T::OutputResource>>, Vec<AnyError>> where
T: Transformation<<Self::SubFragment as Fragment>::Resource, I, Self::SubFragment>,
[src]
&mut self,
fragment: &Either<A, B>,
transform: &mut T,
name: &'static str
) -> Result<Vec<Instruction<T::OutputResource>>, Vec<AnyError>> where
T: Transformation<<Self::SubFragment as Fragment>::Resource, I, Self::SubFragment>,
fn confirm(&mut self, name: &'static str)
[src]
fn abort(&mut self, name: &'static str)
[src]
fn maybe_cached(&self, fragment: &Either<A, B>, name: &'static str) -> bool
[src]
impl<A: Eq, B: Eq> Eq for Either<A, B>
[src]
impl<A, B> Fragment for Either<A, B> where
A: Fragment,
A::Driver: Driver<A, SubFragment = A>,
B: Fragment,
B::Driver: Driver<B, SubFragment = B>,
[src]
A: Fragment,
A::Driver: Driver<A, SubFragment = A>,
B: Fragment,
B::Driver: Driver<B, SubFragment = B>,
type Driver = EitherDriver<A, B>
The default driver to be used by the fragment. Read more
type Installer = EitherInstaller<A::Installer, B::Installer>
The default installer to be used unless a transformation or the user doesn’t provide one. Read more
type Seed = Either<A::Seed, B::Seed>
The intermediate product if the fragment supports two-stage creation of
Resource
s. If not, it can be set to ()
. Read more
type Resource = Either<A::Resource, B::Resource>
The actual product this Fragment
creates.
fn make_seed(&self, name: &'static str) -> Result<Self::Seed, AnyError>
[src]
fn make_resource(
&self,
seed: &mut Self::Seed,
name: &'static str
) -> Result<Self::Resource, AnyError>
[src]
&self,
seed: &mut Self::Seed,
name: &'static str
) -> Result<Self::Resource, AnyError>
pub const RUN_BEFORE_CONFIG: bool
[src]
pub fn create(
&self,
name: &'static str
) -> Result<Self::Resource, Box<dyn Error + 'static + Sync + Send, Global>>
[src]
&self,
name: &'static str
) -> Result<Self::Resource, Box<dyn Error + 'static + Sync + Send, Global>>
pub fn init<B>(
builder: B,
&'static str
) -> Result<B, Box<dyn Error + 'static + Sync + Send, Global>> where
B: Extensible<Ok = B>,
<B as Extensible>::Config: DeserializeOwned,
<B as Extensible>::Config: Send,
<B as Extensible>::Config: Sync,
<B as Extensible>::Config: 'static,
<B as Extensible>::Opts: StructOpt,
<B as Extensible>::Opts: Send,
<B as Extensible>::Opts: Sync,
<B as Extensible>::Opts: 'static,
[src]
builder: B,
&'static str
) -> Result<B, Box<dyn Error + 'static + Sync + Send, Global>> where
B: Extensible<Ok = B>,
<B as Extensible>::Config: DeserializeOwned,
<B as Extensible>::Config: Send,
<B as Extensible>::Config: Sync,
<B as Extensible>::Config: 'static,
<B as Extensible>::Opts: StructOpt,
<B as Extensible>::Opts: Send,
<B as Extensible>::Opts: Sync,
<B as Extensible>::Opts: 'static,
impl<A, B> From<Either<A, B>> for Either<A, B>
[src]
impl<A, B> From<Either<A, B>> for Either<A, B>
[src]
fn from(e: OtherEither<A, B>) -> Self
[src]
impl<A, B> Future for Either<A, B> where
A: Future,
B: Future,
[src]
A: Future,
B: Future,
type Output = Either<A::Output, B::Output>
The type of value produced on completion.
fn poll(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Self::Output>
[src]
impl<A: Hash, B: Hash> Hash for Either<A, B>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<A, B, RA, RB, O, C> Installer<Either<RA, RB>, O, C> for EitherInstaller<A, B> where
A: Installer<RA, O, C>,
B: Installer<RB, O, C>,
[src]
A: Installer<RA, O, C>,
B: Installer<RB, O, C>,
type UninstallHandle = Either<A::UninstallHandle, B::UninstallHandle>
A handle representing lifetime of the resource. Read more
fn install(
&mut self,
resource: Either<RA, RB>,
name: &'static str
) -> Self::UninstallHandle
[src]
&mut self,
resource: Either<RA, RB>,
name: &'static str
) -> Self::UninstallHandle
fn init<E: Extensible<Opts = O, Config = C, Ok = E>>(
&mut self,
builder: E,
name: &'static str
) -> Result<E, AnyError> where
E::Config: DeserializeOwned + Send + Sync + 'static,
E::Opts: StructOpt + Send + Sync + 'static,
[src]
&mut self,
builder: E,
name: &'static str
) -> Result<E, AnyError> where
E::Config: DeserializeOwned + Send + Sync + 'static,
E::Opts: StructOpt + Send + Sync + 'static,
impl<A, B> Into<Either<A, B>> for Either<A, B>
[src]
impl<A, B> Into<Either<A, B>> for Either<A, B>
[src]
fn into(self) -> OtherEither<A, B>
[src]
impl<A: Ord, B: Ord> Ord for Either<A, B>
[src]
fn cmp(&self, other: &Either<A, B>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<A: PartialEq, B: PartialEq> PartialEq<Either<A, B>> for Either<A, B>
[src]
impl<A: PartialOrd, B: PartialOrd> PartialOrd<Either<A, B>> for Either<A, B>
[src]
fn partial_cmp(&self, other: &Either<A, B>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<A, B> Serialize for Either<A, B> where
A: Serialize,
B: Serialize,
[src]
A: Serialize,
B: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<A, B> Stackable for Either<A, B> where
A: Stackable,
B: Stackable,
[src]
A: Stackable,
B: Stackable,
impl<A, B> Stream for Either<A, B> where
A: Stream,
B: Stream,
[src]
A: Stream,
B: Stream,
type Item = Either<A::Item, B::Item>
Values yielded by the stream.
fn poll_next(
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
ctx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
pub fn size_hint(&self) -> (usize, Option<usize>)
impl<A, B> StructDoc for Either<A, B> where
A: StructDoc,
B: StructDoc,
[src]
A: StructDoc,
B: StructDoc,
fn document() -> Documentation
[src]
impl<A, B> StructuralEq for Either<A, B>
[src]
impl<A, B> StructuralPartialEq for Either<A, B>
[src]
impl<'pin, A, B> Unpin for Either<A, B> where
__Either<'pin, A, B>: Unpin,
[src]
__Either<'pin, A, B>: Unpin,
Auto Trait Implementations
impl<A, B> RefUnwindSafe for Either<A, B> where
A: RefUnwindSafe,
B: RefUnwindSafe,
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Either<A, B> where
A: Send,
B: Send,
A: Send,
B: Send,
impl<A, B> Sync for Either<A, B> where
A: Sync,
B: Sync,
A: Sync,
B: Sync,
impl<A, B> UnwindSafe for Either<A, B> where
A: UnwindSafe,
B: UnwindSafe,
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
[src]
R: AsyncBufRead + ?Sized,
pub fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntil<'a, Self> where
Self: Unpin,
pub fn read_line(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn split(self, byte: u8) -> Split<Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn lines(self) -> Lines<Self>
[src]
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
[src]
R: AsyncRead + ?Sized,
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
[src]
R: AsyncRead,
pub fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_buf<B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B> where
Self: Unpin,
B: BufMut,
[src]
Self: Unpin,
B: BufMut,
pub fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u8(&'a mut self) -> ReadU8<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i8(&'a mut self) -> ReadI8<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u16(&'a mut self) -> ReadU16<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i16(&'a mut self) -> ReadI16<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u32(&'a mut self) -> ReadU32<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i32(&'a mut self) -> ReadI32<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u64(&'a mut self) -> ReadU64<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i64(&'a mut self) -> ReadI64<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u128(&'a mut self) -> ReadU128<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i128(&'a mut self) -> ReadI128<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u16_le(&'a mut self) -> ReadU16Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i16_le(&'a mut self) -> ReadI16Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u32_le(&'a mut self) -> ReadU32Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i32_le(&'a mut self) -> ReadI32Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u64_le(&'a mut self) -> ReadU64Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i64_le(&'a mut self) -> ReadI64Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_u128_le(&'a mut self) -> ReadU128Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_i128_le(&'a mut self) -> ReadI128Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
pub fn read_to_string(
&'a mut self,
dst: &'a mut String
) -> ReadToString<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
dst: &'a mut String
) -> ReadToString<'a, Self> where
Self: Unpin,
pub fn take(self, limit: u64) -> Take<Self>
[src]
impl<S> AsyncSeekExt for S where
S: AsyncSeek + ?Sized,
[src]
S: AsyncSeek + ?Sized,
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
[src]
W: AsyncWrite + ?Sized,
pub fn write(&'a mut self, src: &'a [u8]) -> Write<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_buf<B>(&'a mut self, src: &'a mut B) -> WriteBuf<'a, Self, B> where
Self: Unpin,
B: Buf,
[src]
Self: Unpin,
B: Buf,
pub fn write_all(&'a mut self, src: &'a [u8]) -> WriteAll<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u8(&'a mut self, n: u8) -> WriteU8<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i8(&'a mut self, n: i8) -> WriteI8<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u16(&'a mut self, n: u16) -> WriteU16<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i16(&'a mut self, n: i16) -> WriteI16<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u32(&'a mut self, n: u32) -> WriteU32<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i32(&'a mut self, n: i32) -> WriteI32<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u64(&'a mut self, n: u64) -> WriteU64<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i64(&'a mut self, n: i64) -> WriteI64<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u128(&'a mut self, n: u128) -> WriteU128<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i128(&'a mut self, n: i128) -> WriteI128<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u16_le(&'a mut self, n: u16) -> WriteU16Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i16_le(&'a mut self, n: i16) -> WriteI16Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u32_le(&'a mut self, n: u32) -> WriteU32Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i32_le(&'a mut self, n: i32) -> WriteI32Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u64_le(&'a mut self, n: u64) -> WriteU64Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i64_le(&'a mut self, n: i64) -> WriteI64Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_u128_le(&'a mut self, n: u128) -> WriteU128Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn write_i128_le(&'a mut self, n: i128) -> WriteI128Le<&'a mut Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn flush(&mut self) -> Flush<'_, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn shutdown(&mut self) -> Shutdown<'_, Self> where
Self: Unpin,
[src]
Self: Unpin,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> FutureExt for T where
T: Future + ?Sized,
[src]
T: Future + ?Sized,
pub fn map<U, F>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Output) -> U,
[src]
F: FnOnce(Self::Output) -> U,
pub fn map_into<U>(self) -> MapInto<Self, U> where
Self::Output: Into<U>,
[src]
Self::Output: Into<U>,
pub fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
[src]
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
pub fn left_future<B>(self) -> Either<Self, B> where
B: Future<Output = Self::Output>,
[src]
B: Future<Output = Self::Output>,
pub fn right_future<A>(self) -> Either<A, Self> where
A: Future<Output = Self::Output>,
[src]
A: Future<Output = Self::Output>,
pub fn into_stream(self) -> IntoStream<Self>
[src]
pub fn flatten(self) -> Flatten<Self> where
Self::Output: Future,
[src]
Self::Output: Future,
pub fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
[src]
Self::Output: Stream,
pub fn fuse(self) -> Fuse<Self>
[src]
pub fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnOnce(&Self::Output),
[src]
F: FnOnce(&Self::Output),
pub fn unit_error(self) -> UnitError<Self>
[src]
pub fn never_error(self) -> NeverError<Self>
[src]
pub fn poll_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
[src]
Self: Unpin,
pub fn now_or_never(self) -> Option<Self::Output>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F> IntoFuture for F where
F: Future,
[src]
F: Future,
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type Future = F
into_future
)Which kind of future are we turning this into?
pub fn into_future(self) -> <F as IntoFuture>::Future
[src]
impl<T> IntoResult<T> for T
[src]
impl<F> Optional for F where
F: Stackable,
[src]
F: Stackable,
impl<T> StreamExt for T where
T: Stream + ?Sized,
[src]
T: Stream + ?Sized,
pub fn next(&mut self) -> Next<'_, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn into_future(self) -> StreamFuture<Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn map<T, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> T,
[src]
F: FnMut(Self::Item) -> T,
pub fn enumerate(self) -> Enumerate<Self>
[src]
pub fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F> where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
[src]
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
pub fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
[src]
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = Option<T>>,
pub fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
[src]
F: FnMut(Self::Item) -> Fut,
Fut: Future,
pub fn collect<C>(self) -> Collect<Self, C> where
C: Default + Extend<Self::Item>,
[src]
C: Default + Extend<Self::Item>,
pub fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB> where
Self: Stream<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
[src]
Self: Stream<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
pub fn concat(self) -> Concat<Self> where
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
Self::Item: Default,
[src]
Self::Item: Extend<<Self::Item as IntoIterator>::Item>,
Self::Item: IntoIterator,
Self::Item: Default,
pub fn cycle(self) -> Cycle<Self> where
Self: Clone,
[src]
Self: Clone,
pub fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F> where
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
[src]
F: FnMut(T, Self::Item) -> Fut,
Fut: Future<Output = T>,
pub fn flatten(self) -> Flatten<Self> where
Self::Item: Stream,
[src]
Self::Item: Stream,
pub fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: Stream,
[src]
F: FnMut(Self::Item) -> U,
U: Stream,
pub fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F> where
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
[src]
F: FnMut(&mut S, Self::Item) -> Fut,
Fut: Future<Output = Option<B>>,
pub fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F> where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
[src]
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
pub fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F> where
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
[src]
F: FnMut(&Self::Item) -> Fut,
Fut: Future<Output = bool>,
pub fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut> where
Fut: Future,
[src]
Fut: Future,
pub fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F> where
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
[src]
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()>,
pub fn take(self, n: usize) -> Take<Self>
[src]
pub fn skip(self, n: usize) -> Skip<Self>
[src]
pub fn fuse(self) -> Fuse<Self>
[src]
pub fn by_ref(&mut self) -> &mut Self
[src]
pub fn zip<St>(self, other: St) -> Zip<Self, St> where
St: Stream,
[src]
St: Stream,
pub fn chain<St>(self, other: St) -> Chain<Self, St> where
St: Stream<Item = Self::Item>,
[src]
St: Stream<Item = Self::Item>,
pub fn peekable(self) -> Peekable<Self>
[src]
pub fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
[src]
F: FnMut(&Self::Item),
pub fn left_stream<B>(self) -> Either<Self, B> where
B: Stream<Item = Self::Item>,
[src]
B: Stream<Item = Self::Item>,
pub fn right_stream<B>(self) -> Either<B, Self> where
B: Stream<Item = Self::Item>,
[src]
B: Stream<Item = Self::Item>,
pub fn poll_next_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>> where
Self: Unpin,
[src]
&mut self,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>> where
Self: Unpin,
pub fn select_next_some(&mut self) -> SelectNextSome<'_, Self> where
Self: Unpin + FusedStream,
[src]
Self: Unpin + FusedStream,
impl<St> StreamExt for St where
St: Stream + ?Sized,
[src]
St: Stream + ?Sized,
pub fn next(&mut self) -> Next<'_, Self> where
Self: Unpin,
[src]
Self: Unpin,
pub fn try_next<T, E>(&mut self) -> TryNext<'_, Self> where
Self: Stream<Item = Result<T, E>> + Unpin,
[src]
Self: Stream<Item = Result<T, E>> + Unpin,
pub fn map<T, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> T,
[src]
F: FnMut(Self::Item) -> T,
pub fn merge<U>(self, other: U) -> Merge<Self, U> where
U: Stream<Item = Self::Item>,
[src]
U: Stream<Item = Self::Item>,
pub fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
pub fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<T>,
[src]
F: FnMut(Self::Item) -> Option<T>,
pub fn fuse(self) -> Fuse<Self>
[src]
pub fn take(self, n: usize) -> Take<Self>
[src]
pub fn take_while<F>(self, f: F) -> TakeWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
pub fn skip(self, n: usize) -> Skip<Self>
[src]
pub fn skip_while<F>(self, f: F) -> SkipWhile<Self, F> where
F: FnMut(&Self::Item) -> bool,
[src]
F: FnMut(&Self::Item) -> bool,
pub fn all<F>(&mut self, f: F) -> AllFuture<'_, Self, F> where
Self: Unpin,
F: FnMut(Self::Item) -> bool,
[src]
Self: Unpin,
F: FnMut(Self::Item) -> bool,
pub fn any<F>(&mut self, f: F) -> AnyFuture<'_, Self, F> where
Self: Unpin,
F: FnMut(Self::Item) -> bool,
[src]
Self: Unpin,
F: FnMut(Self::Item) -> bool,
pub fn chain<U>(self, other: U) -> Chain<Self, U> where
U: Stream<Item = Self::Item>,
[src]
U: Stream<Item = Self::Item>,
pub fn fold<B, F>(self, init: B, f: F) -> FoldFuture<Self, B, F> where
F: FnMut(B, Self::Item) -> B,
[src]
F: FnMut(B, Self::Item) -> B,
pub fn collect<T>(self) -> Collect<Self, T> where
T: FromStream<Self::Item>,
[src]
T: FromStream<Self::Item>,
pub fn timeout(self, duration: Duration) -> Timeout<Self>
[src]
pub fn throttle(self, duration: Duration) -> Throttle<Self>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,