pub struct SingBoxProfileConfigurationAdapter { /* private fields */ }Expand description
Owns sing-box native validation and its active JSON file.
apply_and_readback validates before replacing the file, installs the
exact submitted bytes atomically, and verifies those bytes from disk. The
caller still owns process restart/readiness and must not treat this file
receipt as proof that a running core loaded the document. Transactions are
serialized per adapter instance. A config path must have exactly one
adapter owner; separate instances or processes sharing it are not locked.
Implementations§
Source§impl SingBoxProfileConfigurationAdapter
impl SingBoxProfileConfigurationAdapter
Sourcepub fn with_tokio(binary_path: PathBuf, config_path: PathBuf) -> Self
pub fn with_tokio(binary_path: PathBuf, config_path: PathBuf) -> Self
Creates the adapter that launches the binary through tokio.
Sourcepub fn new(
binary_path: PathBuf,
config_path: PathBuf,
command: Arc<dyn SingBoxCommandPort>,
) -> Self
pub fn new( binary_path: PathBuf, config_path: PathBuf, command: Arc<dyn SingBoxCommandPort>, ) -> Self
Creates the adapter with an injected command boundary.
Sourcepub async fn validate_native(
&self,
raw_bytes: &[u8],
) -> Result<DocumentValidation, PortError>
pub async fn validate_native( &self, raw_bytes: &[u8], ) -> Result<DocumentValidation, PortError>
Validates the document with the native sing-box check transaction.
A document that the JSON codec rejects is never staged; a document the codec accepts is staged in a temporary file and checked by the engine.
Sourcepub async fn apply_and_readback(
&self,
raw_bytes: &[u8],
) -> Result<SingBoxConfigApplyReceipt, PortError>
pub async fn apply_and_readback( &self, raw_bytes: &[u8], ) -> Result<SingBoxConfigApplyReceipt, PortError>
Validates, installs and reads back the exact submitted bytes.
A read-back that does not match rolls the previous file back and reports the typed failure.
Sourcepub async fn readback(&self) -> Result<Vec<u8>, PortError>
pub async fn readback(&self) -> Result<Vec<u8>, PortError>
Reads the exact bytes of the active configuration file.
Sourcepub async fn file_state(&self) -> Result<SingBoxConfigFileState, PortError>
pub async fn file_state(&self) -> Result<SingBoxConfigFileState, PortError>
Reads the exact state of the active configuration file.
Sourcepub async fn restore_file_state(
&self,
expected: &SingBoxConfigFileState,
) -> Result<(), PortError>
pub async fn restore_file_state( &self, expected: &SingBoxConfigFileState, ) -> Result<(), PortError>
Restores a transaction snapshot and verifies the resulting file state.