Skip to main content

BridgeBuilder

Struct BridgeBuilder 

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

Builder for Bridge.

Creates paired RX+TX handles on two interfaces. By default both sides inherit a single RingProfile and share promiscuous / qdisc_bypass flags. Per-direction overrides exist for asymmetric setups (e.g., capture jumbo on A, retransmit standard MTU on B).

Promiscuous mode and qdisc bypass are enabled by default (optimal for transparent bridging).

Implementations§

Source§

impl BridgeBuilder

Source

pub fn interface_a(self, name: &str) -> Self

Set interface A (required).

Source

pub fn interface_b(self, name: &str) -> Self

Set interface B (required).

Source

pub fn profile(self, profile: RingProfile) -> Self

Set the ring buffer profile for both interfaces. Default: RingProfile::Default.

Source

pub fn promiscuous(self, enable: bool) -> Self

Enable promiscuous mode on both interfaces. Default: true.

Source

pub fn qdisc_bypass(self, enable: bool) -> Self

Bypass qdisc for TX on both interfaces. Default: true.

Source

pub fn poll_timeout(self, timeout: Duration) -> Self

Maximum time the bridge waits in poll(2) between iterations.

Smaller values reduce shutdown latency at the cost of more frequent syscalls when traffic is sparse. Default: 100 ms.

Source

pub fn a_block_size(self, bytes: usize) -> Self

Override RX block size on interface A. None = inherit from profile.

Source

pub fn a_block_count(self, n: usize) -> Self

Override RX block count on interface A.

Source

pub fn a_frame_size(self, bytes: usize) -> Self

Override RX frame size on interface A.

Source

pub fn a_block_timeout_ms(self, ms: u32) -> Self

Override RX block-retire timeout on interface A.

Source

pub fn b_block_size(self, bytes: usize) -> Self

Override RX block size on interface B.

Source

pub fn b_block_count(self, n: usize) -> Self

Override RX block count on interface B.

Source

pub fn b_frame_size(self, bytes: usize) -> Self

Override RX frame size on interface B.

Source

pub fn b_block_timeout_ms(self, ms: u32) -> Self

Override RX block-retire timeout on interface B.

Source

pub fn tx_a_frame_size(self, bytes: usize) -> Self

Override TX frame size on interface A (B→A direction). None = inherit RX frame_size.

Source

pub fn tx_b_frame_size(self, bytes: usize) -> Self

Override TX frame size on interface B (A→B direction). None = inherit RX frame_size.

Source

pub fn tx_a_frame_count(self, n: usize) -> Self

Override TX frame count on interface A.

Source

pub fn tx_b_frame_count(self, n: usize) -> Self

Override TX frame count on interface B.

Source

pub fn build(self) -> Result<Bridge, Error>

Validate and create the Bridge.

Creates 4 handles: RX on A, TX on B, RX on B, TX on A.

§Errors

Returns Error::Config if interface names are missing, Error::PermissionDenied without CAP_NET_RAW, or other socket/mmap errors.

Trait Implementations§

Source§

impl Default for BridgeBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more