Skip to main content

WfpTransaction

Struct WfpTransaction 

Source
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 succeeded

Implementations§

Source§

impl<'a> WfpTransaction<'a>

Source

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()?;
Source

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 permanent
Source

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.

Source

pub fn is_committed(&self) -> bool

Check if transaction has been committed

Trait Implementations§

Source§

impl<'a> Drop for WfpTransaction<'a>

Source§

fn drop(&mut self)

Automatically rollback transaction if not committed

Auto Trait Implementations§

§

impl<'a> Freeze for WfpTransaction<'a>

§

impl<'a> RefUnwindSafe for WfpTransaction<'a>

§

impl<'a> !Send for WfpTransaction<'a>

§

impl<'a> !Sync for WfpTransaction<'a>

§

impl<'a> Unpin for WfpTransaction<'a>

§

impl<'a> UnsafeUnpin for WfpTransaction<'a>

§

impl<'a> UnwindSafe for WfpTransaction<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.