Skip to main content

azums_core/
lib.rs

1//! # Azums Core
2//!
3//! Zero-dependency core traits, models, and [`QueueError`] for `azums`.
4
5#![deny(unsafe_code)]
6#![allow(clippy::double_must_use)]
7#![cfg_attr(not(feature = "std"), no_std)]
8
9#[cfg(feature = "alloc")]
10extern crate alloc;
11
12pub mod backend;
13pub mod error;
14pub mod model;
15
16pub use backend::{
17    CallRecord, MemoryAttempt, MemoryBackend, MockBackend, NotificationStream, StorageBackend,
18    StreamBackend,
19};
20pub use error::{Error, QueueError};
21pub use model::{
22    ConsumerGroupStatus, Event, Job, JobHandler, JobListItem, JobProcessor, JobStatus, NewEvent,
23    NewJob, QueueConfig, QueueOrdering,
24};
25
26/// Helper function to extract a human-readable panic message string from a panic payload.
27pub fn format_panic_message(err: Box<dyn std::any::Any + Send>) -> String {
28    if let Some(s) = err.downcast_ref::<&str>() {
29        s.to_string()
30    } else if let Some(s) = err.downcast_ref::<String>() {
31        s.clone()
32    } else {
33        "job handler panicked with unknown payload".to_string()
34    }
35}