pub struct WfpTransaction<'a> { /* private fields */ }Expand description
WFP Transaction with RAII rollback support
Automatically begins a transaction on creation and rolls back on drop unless explicitly committed.
§Examples
use windows_wfp::{WfpEngine, WfpTransaction};
let engine = WfpEngine::new()?;
let mut txn = WfpTransaction::begin(&engine)?;
// Perform filter operations...
// If any operation fails, transaction will be rolled back automatically
txn.commit()?; // Explicitly commit if all succeededImplementations§
Source§impl<'a> WfpTransaction<'a>
impl<'a> WfpTransaction<'a>
Sourcepub fn begin(engine: &'a WfpEngine) -> WfpResult<Self>
pub fn begin(engine: &'a WfpEngine) -> WfpResult<Self>
Begin a new WFP transaction
The transaction will automatically rollback if dropped without calling commit().
§Errors
Returns WfpError::TransactionBeginFailed if:
- Another transaction is already active on this session
- WFP engine session is invalid
§Examples
use windows_wfp::{WfpEngine, WfpTransaction};
let engine = WfpEngine::new()?;
let mut txn = WfpTransaction::begin(&engine)?;
// Transaction active...
txn.commit()?;Sourcepub fn commit(self) -> WfpResult<()>
pub fn commit(self) -> WfpResult<()>
Commit the transaction
Makes all changes permanent. If not called, the transaction will automatically rollback when dropped.
§Errors
Returns WfpError::TransactionCommitFailed if the commit operation fails.
§Examples
use windows_wfp::{WfpEngine, WfpTransaction};
let engine = WfpEngine::new()?;
let mut txn = WfpTransaction::begin(&engine)?;
// Perform operations...
txn.commit()?; // Make changes permanentSourcepub fn rollback(self) -> WfpResult<()>
pub fn rollback(self) -> WfpResult<()>
Explicitly rollback the transaction
This is optional - the transaction will rollback automatically on drop if not committed. Use this for explicit error handling.
§Errors
Returns WfpError::TransactionAbortFailed if the abort operation fails.
Sourcepub fn is_committed(&self) -> bool
pub fn is_committed(&self) -> bool
Check if transaction has been committed