Struct async_slot::sync::Sender [] [src]

pub struct Sender<T> { /* fields omitted */ }

Slot is very similar to unbounded channel but only stores last value sent

I.e. if you want to send some value between from producer to a consumer and if consumer is slow it should skip old values, the slot is a structure for the task. The transmission end of a channel which is used to send values

If the receiver is not fast enough only the last value is preserved and other ones are discarded.

Methods

impl<T> Sender<T>
[src]

[src]

Sets the new new value of the stream and notifies the consumer if any

This function will store the value provided as the current value for this channel, replacing any previous value that may have been there. If the receiver may still be able to receive this message, then Ok is returned with the previous value that was in this channel.

If Ok(Some) is returned then this value overwrote a previous value, and the value was never received by the receiver. If Ok(None) is returned, then no previous value was found and the value is queued up to be received by the receiver.

Errors

This function will return an Err if the receiver has gone away and it's impossible to send this value to the receiver. The error returned retains ownership of the value provided and can be extracted, if necessary.

[src]

Polls this Sender half to detect whether the Receiver this has paired with has gone away.

This function can be used to learn about when the Receiver (consumer) half has gone away and nothing will be able to receive a message sent from send (or swap).

If Ready is returned then it means that the Receiver has disappeared and the result this Sender would otherwise produce should no longer be produced.

If NotReady is returned then the Receiver is still alive and may be able to receive a message if sent. The current task, however, is scheduled to receive a notification if the corresponding Receiver goes away.

Panics

Like Future::poll, this function will panic if it's not called from within the context of a task. In other words, this should only ever be called from inside another future.

If you're calling this function from a context that does not have a task, then you can use the is_canceled API instead.

[src]

Tests to see whether this Sender's corresponding Receiver has gone away.

This function can be used to learn about when the Receiver (consumer) half has gone away and nothing will be able to receive a message sent from send.

Note that this function is intended to not be used in the context of a future. If you're implementing a future you probably want to call the poll_cancel function which will block the current task if the cancellation hasn't happened yet. This can be useful when working on a non-futures related thread, though, which would otherwise panic if poll_cancel were called.

Trait Implementations

impl<T: Debug> Debug for Sender<T>
[src]

[src]

Formats the value using the given formatter.

impl<T> Sink for Sender<T>
[src]

The type of value that the sink accepts.

The type of value produced by the sink when an error occurs.

[src]

Begin the process of sending a value to the sink. Read more

[src]

Flush all output from this sink, if necessary. Read more

[src]

A method to indicate that no more values will ever be pushed into this sink. Read more

[src]

Creates a new object which will produce a synchronous sink. Read more

[src]

Composes a function in front of the sink. Read more

[src]

Composes a function in front of the sink. Read more

[src]

Transforms the error returned by the sink.

[src]

Map this sink's error to any error implementing From for this sink's Error, returning a new sink. Read more

[src]

Adds a fixed-size buffer to the current sink. Read more

[src]

A future that completes when the sink has finished processing all pending requests. Read more

[src]

A future that completes after the given item has been fully processed into the sink, including flushing. Read more

[src]

A future that completes after the given stream has been fully processed into the sink, including flushing. Read more

impl<T> Drop for Sender<T>
[src]

[src]

Executes the destructor for this type. Read more