Skip to main content

guardrail_core/
lib.rs

1//! # guardrail-core
2//!
3//! Core types, pipeline, and stage trait for `guardrail-rs` — a zero-Python
4//! LLM security proxy written in Rust.
5//!
6//! This crate contains no I/O and no async runtime. It is purely the data model
7//! and the pipeline abstraction that all other crates build upon.
8//!
9//! ## Feature flags
10//!
11//! | Flag | Description | Default |
12//! |------|-------------|---------|
13//! | *(none)* | Base functionality, always enabled | — |
14//!
15//! ## Quick example
16//!
17//! ```rust
18//! use guardrail_core::{Pipeline, PipelineBuilder, Decision};
19//!
20//! // Build a pipeline (stages added by guardrail-classifiers)
21//! let pipeline = PipelineBuilder::default().build();
22//!
23//! // A pipeline with no stages always allows
24//! # tokio_test::block_on(async {
25//! let req = guardrail_core::test_helpers::clean_request();
26//! let (decision, _req) = pipeline.run(req).await.unwrap();
27//! assert_eq!(decision, Decision::Allow);
28//! # });
29//! ```
30//!
31//! ## Further reading
32//!
33//! - [Configuration reference](https://github.com/Mattral/guardrail-rs/blob/main/docs/configuration.md) —
34//!   the full TOML schema for assembling a [`Pipeline`] via `guardrail-config`.
35//! - [Threat model](https://github.com/Mattral/guardrail-rs/blob/main/docs/threat-model.md) —
36//!   what guardrail-rs protects against and its explicit trust boundaries.
37//! - [Stage API reference](https://github.com/Mattral/guardrail-rs/blob/main/docs/stage-api.md) —
38//!   the contract every [`Stage`] implementation must satisfy.
39//! - [Changelog](https://github.com/Mattral/guardrail-rs/blob/main/CHANGELOG.md) —
40//!   release history and notable changes.
41
42#![deny(missing_docs)]
43#![warn(clippy::all)]
44
45pub mod decision;
46pub mod error;
47pub mod pipeline;
48pub mod policy;
49pub mod request;
50
51#[allow(missing_docs)]
52pub mod test_helpers;
53
54pub use decision::{BlockCode, Decision};
55pub use error::GuardrailError;
56pub use pipeline::{FailMode, Pipeline, PipelineBuilder, Stage, StageEvent, StageOutcome};
57pub use request::{ChatMessage, ContentPart, GuardrailRequest, MessageContent, Provider, Role};