mediatrix/
lib.rs

1//! mediatrix provides multiple strongly-typed mediators for synchronous and asynchronous needs.
2//!
3//! # Quick Start
4//!
5//! For synchronous needs, the [`BasicMediator`] suffices.
6//! The [`BasicAsyncMediator`] on the other hand is needed for asynchronous
7//! handlers.
8//! If you need your handler to include some sort of context,
9//! use the [`CxAwareAsyncMediator`]. This mediator requires a user-defined
10//! type to be injected through its builder.
11//!
12//! # Crate Architecture
13//!
14//! The crate is structured in an additive way.
15//! The [`BasicMediator`] is used as a basis for [`BasicAsyncMediator`].
16//! In turn, the [`BasicAsyncMediator`] is used as a basis for the [`CxAwareAsyncMediator`].
17//! This way, code duplication is minimal and the code in general is less error-prone.
18//!
19//! Each mediator consists of a module for its own builder, interface and the implementation itself.
20//!
21//! Builders implement basic functionality [`builder::BuilderInternal`] and [`builder::BuilderFlow`] if
22//! the builder is required to always be able to return a valid mediator.
23//! Otherwise, builders implement [`builder::TryBuilderInternal`] and [`builder::TryBuilderFlow`],
24//! which results in a return value of  [`Result<M, Self::Error>`], where `M` is the mediator type.
25//!
26//! Interfaces contain trait definitions highlighting the user-facing API,
27//! which are implemented by their mediator.
28//!
29//! Lastly, the module for the mediator itself contains
30//! internal structure and implementation details for the
31//! respective mediator.
32//!
33//! [`BasicMediator`]: synchronous::basic::BasicMediator
34//! [`BasicAsyncMediator`]: asynchronous::basic::BasicAsyncMediator
35//! [`CxAwareAsyncMediator`]: asynchronous::contextaware::CxAwareAsyncMediator
36
37#![doc(html_root_url = "https://docs.rs/mediatrix/1.0.0")]
38#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
39#![deny(missing_docs, unused_imports, unsafe_code)]
40
41mod mediator;
42
43#[cfg(feature = "async")]
44pub use mediator::asynchronous;
45pub use mediator::builder;
46pub use mediator::listener;
47pub use mediator::synchronous;
48
49#[cfg(test)]
50mod test;