Skip to main content

Rule

Struct Rule 

Source
pub struct Rule { /* private fields */ }
Expand description

A rule for controlling packet routing. Rules can be build with RuleBuilder and require at least one filter constraint, and an action.

Implementations§

Source§

impl Rule

Source

pub fn builder() -> RuleBuilder

Creates a RuleBuilder

Source

pub fn action(action: Action) -> RuleBuilder

Creates a RuleBuilder and sets the rule’s Action

The action applies to all packets matching the rule, unless overridden by successive rules.

Source

pub fn protocol(protocol: Protocol) -> RuleBuilder

Creates a RuleBuilder and sets the rule’s Protocol

Source

pub fn source_cidr(cidr_range: impl IntoIpNet) -> RuleBuilder

Creates a RuleBuilder and sets the source CIDR.

Accepts any IP address or CIDR notation:

  • "127.0.0.1": matches a single IP
  • "10.0.0.0/24": matches a CIDR

This additionally accepts std::net::IpAddr, std::net::Ipv4Addr, std::net::Ipv6Addr, ipnet::IpNet, ipnet::Ipv4Net, and ipnet::Ipv6Net.

Source

pub fn source_port(port: impl IntoPortRange) -> RuleBuilder

Creates a RuleBuilder and sets the source port

Accepts a u16 or range

Source

pub fn destination_cidr(cidr_range: impl IntoIpNet) -> RuleBuilder

Creates a RuleBuilder and sets the destination CIDR.

Accepts any IP address or CIDR notation:

  • "127.0.0.1": matches a single IP
  • "10.0.0.0/24": matches a CIDR

This additionally accepts std::net::IpAddr, std::net::Ipv4Addr, std::net::Ipv6Addr, ipnet::IpNet, ipnet::Ipv4Net, and ipnet::Ipv6Net.

Source

pub fn destination_port(port: impl IntoPortRange) -> RuleBuilder

Creates a RuleBuilder and sets the destination port

Accepts a u16 or range

Trait Implementations§

Source§

impl From<&Rule> for Ipv4Rule

Source§

fn from(value: &Rule) -> Self

Converts to this type from the input type.
Source§

impl From<&Rule> for Ipv6Rule

Source§

fn from(value: &Rule) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<RuleBuilder> for Rule

Source§

type Error = RuleError

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

fn try_from(value: RuleBuilder) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Rule

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnsafeUnpin for Rule

§

impl UnwindSafe for Rule

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.