blueprint_router/lib.rs
1//! Blueprint SDK Job Router
2//!
3//! This crate provides the [`Router`], which is used to route jobs to different handlers based on their [`JobId`].
4//!
5//! # Usage
6//!
7//! ```rust
8//! use blueprint_sdk::Router;
9//! use blueprint_sdk::job::JobWithoutContextExt;
10//! use blueprint_sdk::{IntoJobResult, JobResult};
11//!
12//! // Define a job function. See [`Job`] for more details
13//! async fn my_job() -> String {
14//! String::from("Hello world!")
15//! }
16//!
17//! // Give the job some kind of ID. Many types can be converted
18//! // into a [`JobId`]. See [`JobId`] for more details
19//! const MY_JOB_ID: u32 = 0;
20//!
21//! let router = Router::new().route(MY_JOB_ID, my_job);
22//!
23//! # let _: Router = router;
24//! ```
25//!
26//! # See also
27//!
28//! - [`Job`](https://docs.rs/blueprint_sdk/latest/blueprint_sdk/trait.Job.html)
29//! - [`JobId`]
30//!
31//! [`JobId`]: https://docs.rs/blueprint_sdk/latest/blueprint_sdk/struct.JobId.html
32//!
33//! ## Features
34#![doc = document_features::document_features!()]
35#![cfg_attr(docsrs, feature(doc_auto_cfg))]
36#![doc(
37 html_logo_url = "https://cdn.prod.website-files.com/6494562b44a28080aafcbad4/65aaf8b0818b1d504cbdf81b_Tnt%20Logo.png"
38)]
39#![no_std]
40
41extern crate alloc;
42
43#[doc(hidden)]
44pub mod __private {
45 #[cfg(feature = "tracing")]
46 pub use blueprint_core::__private::tracing;
47}
48
49mod boxed;
50pub mod future;
51mod job_id_router;
52mod routing;
53mod util;
54
55#[cfg(test)]
56pub(crate) mod test_helpers;
57#[cfg(test)]
58mod tests;
59
60pub use routing::*;