pub struct Sender<T> { /* private fields */ }
Expand description
Send values to the associated Receiver
.
Instances are created by the channel
function.
Implementations
sourceimpl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn poll_ready(&mut self) -> Result<Async<()>, SendError>
pub fn poll_ready(&mut self) -> Result<Async<()>, SendError>
Check if the Sender
is ready to handle a value.
Polls the channel to determine if there is guaranteed capacity to send at least one item without waiting.
When poll_ready
returns Ready
, the channel reserves capacity for one
message for this Sender
instance. The capacity is held until a message
is send or the Sender
instance is dropped. Callers should ensure a
message is sent in a timely fashion in order to not starve other
Sender
instances.
Return value
This method returns:
Ok(Async::Ready(_))
if capacity is reserved for a single message.Ok(Async::NotReady)
if the channel may not have capacity, in which case the current task is queued to be notified once capacity is available;Err(SendError)
if the receiver has been dropped.
sourcepub fn try_send(&mut self, message: T) -> Result<(), TrySendError<T>>
pub fn try_send(&mut self, message: T) -> Result<(), TrySendError<T>>
Attempts to send a message on this Sender
, returning the message
if there was an error.
Trait Implementations
sourceimpl<T> Sink for Sender<T>
impl<T> Sink for Sender<T>
type SinkItem = T
type SinkItem = T
The type of value that the sink accepts.
sourcepub fn start_send(
&mut self,
msg: T
) -> Result<AsyncSink<T>, <Sender<T> as Sink>::SinkError>
pub fn start_send(
&mut self,
msg: T
) -> Result<AsyncSink<T>, <Sender<T> as Sink>::SinkError>
Begin the process of sending a value to the sink. Read more
sourcepub fn poll_complete(
&mut self
) -> Result<Async<()>, <Sender<T> as Sink>::SinkError>
pub fn poll_complete(
&mut self
) -> Result<Async<()>, <Sender<T> as Sink>::SinkError>
Flush all output from this sink, if necessary. Read more
sourcepub fn close(&mut self) -> Result<Async<()>, <Sender<T> as Sink>::SinkError>
pub fn close(&mut self) -> Result<Async<()>, <Sender<T> as Sink>::SinkError>
A method to indicate that no more values will ever be pushed into this sink. Read more
sourcefn wait(self) -> Wait<Self>
fn wait(self) -> Wait<Self>
Creates a new object which will produce a synchronous sink. Read more
sourcefn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut> where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut> where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Composes a function in front of the sink. Read more
sourcefn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St> where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St> where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Composes a function in front of the sink. Read more
sourcefn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::SinkError) -> E,
fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::SinkError) -> E,
Transforms the error returned by the sink.
sourcefn sink_from_err<E>(self) -> SinkFromErr<Self, E> where
E: From<Self::SinkError>,
fn sink_from_err<E>(self) -> SinkFromErr<Self, E> where
E: From<Self::SinkError>,
Map this sink’s error to any error implementing From
for this sink’s
Error
, returning a new sink. Read more
sourcefn buffer(self, amt: usize) -> Buffer<Self>
fn buffer(self, amt: usize) -> Buffer<Self>
Adds a fixed-size buffer to the current sink. Read more
sourcefn fanout<S>(self, other: S) -> Fanout<Self, S> where
S: Sink<SinkItem = Self::SinkItem, SinkError = Self::SinkError>,
Self::SinkItem: Clone,
fn fanout<S>(self, other: S) -> Fanout<Self, S> where
S: Sink<SinkItem = Self::SinkItem, SinkError = Self::SinkError>,
Self::SinkItem: Clone,
Fanout items to multiple sinks. Read more
sourcefn flush(self) -> Flush<Self>
fn flush(self) -> Flush<Self>
A future that completes when the sink has finished processing all pending requests. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T> where
T: Send,
impl<T> Sync for Sender<T> where
T: Send,
impl<T> Unpin for Sender<T>
impl<T> !UnwindSafe for Sender<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more