pub trait EventQueue<T>:
Send
+ Sync
+ 'static {
// Required methods
fn new(capacity: Option<usize>) -> Self;
fn publish(&self, item: T) -> impl Future<Output = Result<()>> + Send;
fn try_publish(&self, item: T) -> Result<(), TryPublishError<T>>;
fn close(&self) -> impl Future<Output = ()> + Send;
fn recv(&self) -> impl Future<Output = Result<T>> + Send;
}Expand description
Async queue used by generated mediators to enqueue events and dequeue them in a background processing loop.
§Type parameters
T— The job/enum type that the generated mediator uses to represent all possible events across its subscribed modules.
Required Methods§
Sourcefn new(capacity: Option<usize>) -> Self
fn new(capacity: Option<usize>) -> Self
Create a new queue.
Some(capacity) requests a bounded queue; None requests an
unbounded queue. Adapters may ignore the hint if the underlying
channel does not support bounding.
Sourcefn publish(&self, item: T) -> impl Future<Output = Result<()>> + Send
fn publish(&self, item: T) -> impl Future<Output = Result<()>> + Send
Enqueue an item.
Returns Error::EventPublishingError
if the channel is closed or full.
Sourcefn try_publish(&self, item: T) -> Result<(), TryPublishError<T>>
fn try_publish(&self, item: T) -> Result<(), TryPublishError<T>>
Attempt to enqueue an item without waiting for queue capacity.
Returns the original item in TryPublishError when the queue is
full or no longer accepts events.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".