Skip to main content

kamu_snap_response/
lib.rs

1//! Framework-agnostic response envelope + error taxonomy for SNAP BI.
2//!
3//! This crate is the response half of the SNAP BI spine (the crypto half lives
4//! in `kamu-snap-crypto`). It exposes:
5//!
6//! - [`SnapResponse<T>`] — typed envelope + optional typed payload with
7//!   spec-compliant flat JSON wire shape.
8//! - [`SnapEnvelope`] — the envelope fields (`responseCode` +
9//!   `responseMessage`).
10//! - [`Error`] — the 61-variant SNAP BI error taxonomy plus a feature-gated
11//!   `Crypto` bridge (feature `crypto`).
12//! - [`Category`] — coarse retry/policy classification.
13//! - [`ResponseCode`] — wire newtype with defensive parsing + an inverse
14//!   classifier that maps received codes back to [`Error`] variants.
15//! - [`ServiceCode`] — validated 0..=99 newtype.
16//!
17//! # Framework support
18//!
19//! This crate is framework-free. The `Responder` (actix-web) and
20//! `IntoResponse` (axum) impls live in the per-framework adapter crates
21//! (`kamu-snap-response-actix`, `kamu-snap-response-axum`).
22//!
23//! # Feature flags
24//!
25//! - `crypto` (default off) — enables the `Error::Crypto` variant which wraps a
26//!   `kamu_snap_crypto::Error` for server-side handlers that propagate crypto
27//!   failures into the SNAP error taxonomy.
28
29#![forbid(unsafe_code)]
30
31pub mod category;
32pub mod envelope;
33pub mod error;
34pub mod response_code;
35
36pub use category::Category;
37pub use envelope::{SnapEnvelope, SnapResponse};
38pub use error::Error;
39pub use response_code::{ResponseCode, ServiceCode};