singbox_driver/lib.rs
1#![warn(missing_docs)]
2//! Engine driver for the sing-box core.
3//!
4//! The driver owns the engine-specific control API client, outbound/routing
5//! observation, readiness probe, native configuration codec and process
6//! supervision. It carries no product type, platform host or UI dependency.
7//!
8//! Feature slices: `http` (Clash API, readiness, outbound, routing intent),
9//! `process` (process supervision) and `codec` (native JSON codec, which drives
10//! the process command boundary). Binary version probing is always available.
11//!
12//! # Example
13//!
14//! ```
15//! use singbox_driver::codec::profile_document_codec::{
16//! PROFILE_FORMAT, PROFILE_SCHEMA_VERSION, SingBoxProfileDocumentCodec,
17//! };
18//! use lurker_core_ports::profile_document_codec::ProfileDocumentCodecPort;
19//!
20//! let codec = SingBoxProfileDocumentCodec;
21//!
22//! // The codec is pure: it inspects exact bytes and never touches storage.
23//! assert_eq!(codec.scope().format_id.as_str(), PROFILE_FORMAT);
24//! assert_eq!(codec.scope().schema_version.value(), PROFILE_SCHEMA_VERSION);
25//!
26//! // A valid document is a JSON object ...
27//! assert!(matches!(
28//! codec.inspect(br#"{"outbounds": []}"#).expect("inspection never fails"),
29//! lurker_core_contract::profile_document::DocumentValidation::Valid
30//! ));
31//!
32//! // ... and a syntactically broken document is reported, not guessed.
33//! assert!(matches!(
34//! codec.inspect(b"{").expect("inspection never fails"),
35//! lurker_core_contract::profile_document::DocumentValidation::Invalid { .. }
36//! ));
37//! ```
38
39#[cfg(feature = "http")]
40pub mod api;
41#[cfg(feature = "backend")]
42pub mod backend;
43#[cfg(feature = "codec")]
44pub mod codec;
45#[cfg(feature = "process")]
46pub mod driver;
47#[cfg(feature = "http")]
48pub mod outbound;
49#[cfg(feature = "process")]
50pub mod process;
51#[cfg(feature = "http")]
52pub mod readiness;
53#[cfg(feature = "http")]
54pub mod routing_intent;
55pub mod version;
56
57#[cfg(all(test, feature = "backend"))]
58#[path = "backend_tests.rs"]
59mod backend_tests;
60#[cfg(all(test, feature = "http"))]
61mod test_support;