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