Skip to main content

Rule

Struct Rule 

Source
pub struct Rule<'a> { /* private fields */ }
Expand description

A nftables firewall rule.

Implementations§

Source§

impl<'a> Rule<'a>

Source

pub fn new(chain: &'a Chain<'_>) -> Rule<'a>

Creates a new rule object in the given Chain.

Source

pub fn set_position(&mut self, position: u64)

Sets the position of this rule within the chain it lives in. By default a new rule is added to the end of the chain.

Source

pub fn set_handle(&mut self, handle: u64)

Source

pub fn add_expr(&mut self, expr: &impl Expression)

Adds an expression to this rule. Expressions are evaluated from first to last added. As soon as an expression does not match the packet it’s being evaluated for, evaluation stops and the packet is evaluated against the next rule in the chain.

Source

pub fn set_comment<T: AsRef<CStr>>( &mut self, comment: T, ) -> Result<(), &'static str>

Add a comment to this rule.

Returns Err if comment is too large.

Source

pub fn get_chain(&self) -> &Chain<'_>

Returns a reference to the Chain this rule lives in.

Trait Implementations§

Source§

impl Drop for Rule<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl NlMsg for Rule<'_>

Source§

unsafe fn write(&self, buf: *mut c_void, seq: u32, msg_type: MsgType)

Serializes the Netlink message to the buffer at buf. buf must have space for at least nft_nlmsg_maxsize() bytes. This is not checked by the compiler, which is why this method is unsafe. Read more
Source§

impl Send for Rule<'_>

Source§

impl Sync for Rule<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Rule<'a>

§

impl<'a> RefUnwindSafe for Rule<'a>

§

impl<'a> Unpin for Rule<'a>

§

impl<'a> UnsafeUnpin for Rule<'a>

§

impl<'a> UnwindSafe for Rule<'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.