brazier 0.1.0

A mediator implementation in Rust, heavily inspired by the .NET MediatR package (https://github.com/jbogard/MediatR).
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented1 out of 8 items with examples
  • Size
  • Source code size: 15.01 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.57 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • yves-bonami/brazier
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yves-bonami

Brazier

crates.io Rust

An implemenation of the mediator pattern.

Brazier is heavily inspired by the .NET MediatR pacakage. It allows you to decouple the sending of a message and the handling of it.

Example

use brazier::*;

pub struct Ping {}

impl Request<String> for Ping {}

#[derive(Debug)]
pub struct PingHandler;

#[async_trait::async_trait]
impl RequestHandler<Ping, String> for PingHandler {
    async fn handle(&mut self, _request: Ping) -> Result<String> {
        Ok(String::from("pong!"))
    }
}

#[tokio::main]
async fn main() -> Result<()> {
    let mut mediator = Mediator::new();
    mediator.register_handler(PingHandler);
    let result = mediator.send(Ping {}).await?;
    println!("{}", result);
    Ok(())
}