Skip to main content

eventbus_core/
lib.rs

1#![allow(async_fn_in_trait)]
2//! Object-safe event-bus contract: traits, value types, and the generic
3//! Stream bus.
4//!
5//! - [`Publisher`] / [`Subscriber`] / [`Bus`] — dyn-safe core traits
6//! - [`PublisherExt`] / [`SubscriberExt`] — monomorphic convenience extensions
7//! - [`Handler`] receives `Box<dyn DeliveryHandle>`
8//! - [`Delivery`] (read) + [`DeliveryControl`] (consume `Box<Self>`) — the
9//!   compiler enforces finalize-at-most-once
10//! - [`stream::StreamBus`] over [`stream::StreamBackend`]; concrete backends
11//!   live in sibling crates (`eventbus-memory`, `eventbus-redis`).
12//!
13//! See the [`eventbus`](https://docs.rs/eventbus) facade crate for ready-to-use
14//! backends behind feature flags.
15
16use std::{future::Future, pin::Pin};
17
18pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
19pub type BoxedError = Box<dyn std::error::Error + Send + Sync + 'static>;
20
21pub mod contract;
22pub mod error;
23pub mod eventbus;
24pub mod serde_bytes;
25pub mod stream;
26
27pub use contract::delivery::{
28    DeliveryInspector, DeliveryOutcome, DeliveryState, PartialDeliveryState,
29};
30pub use contract::message::{
31    SchemaDescriptor, TraceContext, HEADER_BAGGAGE, HEADER_CONTENT_TYPE, HEADER_DEAD_LETTER_REASON,
32    HEADER_EVENT_VERSION, HEADER_IDEMPOTENCY_KEY, HEADER_RETRY_ATTEMPT, HEADER_RETRY_REASON,
33    HEADER_TRACE_PARENT, HEADER_TRACE_STATE,
34};
35pub use contract::{
36    AckMode, BackpressurePolicy, ConsumerBalanceMode, DeliveryGuarantee, GuaranteeMatrix,
37    OrderingMode, OverflowStrategy, PublishConfirmation, SubscriptionSemantics,
38};
39pub use error::EventBusError;
40pub use eventbus::{
41    BatchError, BatchOutcome, Bus, Codec, ConsumerGroup, ConsumerName, Delivery, DeliveryControl,
42    DeliveryHandle, Handler, Headers, Message, MessageId, PublishOptions, Publisher, PublisherExt,
43    Subscriber, SubscriberExt, Subscription, SubscriptionConfig, SubscriptionConfigBuilder, Topic,
44};
45pub use stream::{ErrorObserver, ErrorScope, FetchedEntry, StreamBus, StreamBusOptions};