pub struct ExpiringPublisher<Message> { /* private fields */ }
Expand description

An ‘expiring’ publisher is one that responds to backpressure from its subscribers by expiring the most recent message.

Usually when a subscriber stalls in processing, a publisher will refuse to accept further messages and block. This will avoid blocking by instead expiring messages that cannot be processed.

This is useful in a few situations. One important example is distributing state: say you want to indicate to another thread what your current state is, but if it’s busy you don’t want to wait for it to consume the previous state before you can finish updating the latest state.

Another example is signalling. An ExpiringPublisher<()> can be used to signal that an event has occurred but will not block if all subscribers have not responded in the case where the event occurs multiple times.

Implementations§

Creates a new expiring publisher with a particular buffer size

Once a subscriber has buffer_size messages, this publisher will start to drop the oldest messages.

Counts the number of subscribers in this publisher

Creates a duplicate publisher that can be used to publish to the same streams as this object

Trait Implementations§

Executes the destructor for this type. Read more

Subscribes to this publisher

Subscribers only receive messages sent to the publisher after they are created.

The type of value that the sink accepts.
The type of value produced by the sink when an error occurs.
Begin the process of sending a value to the sink. Read more
Flush all output from this sink, if necessary. Read more
A method to indicate that no more values will ever be pushed into this sink. Read more
Creates a new object which will produce a synchronous sink. Read more
Composes a function in front of the sink. Read more
Composes a function in front of the sink. Read more
Transforms the error returned by the sink.
Map this sink’s error to any error implementing From for this sink’s Error, returning a new sink. Read more
Adds a fixed-size buffer to the current sink. Read more
A future that completes when the sink has finished processing all pending requests. Read more
A future that completes after the given item has been fully processed into the sink, including flushing. Read more
A future that completes after the given stream has been fully processed into the sink, including flushing. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.