IpStackConfig

Struct IpStackConfig 

Source
#[non_exhaustive]
pub struct IpStackConfig { pub mtu: u16, pub packet_information: bool, pub tcp_config: Arc<TcpConfig>, pub udp_timeout: Duration, }
Expand description

Configuration for the IP stack.

This structure holds configuration parameters that control the behavior of the IP stack, including network settings and protocol-specific timeouts.

§Examples

use ipstack::IpStackConfig;
use std::time::Duration;

let mut config = IpStackConfig::default();
config.mtu(1500).expect("Failed to set MTU")
      .udp_timeout(Duration::from_secs(60))
      .packet_information(false);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§mtu: u16

Maximum Transmission Unit (MTU) size in bytes. Default is MIN_MTU (1280).

§packet_information: bool

Whether to include packet information headers (Unix platforms only). Default is false.

§tcp_config: Arc<TcpConfig>

TCP-specific configuration parameters.

§udp_timeout: Duration

Timeout for UDP connections. Default is 30 seconds.

Implementations§

Source§

impl IpStackConfig

Source

pub fn with_tcp_config(&mut self, config: TcpConfig) -> &mut Self

Set custom TCP configuration.

§Arguments
  • config - The TCP configuration to use
§Examples
use ipstack::{IpStackConfig, TcpConfig};

let mut config = IpStackConfig::default();
config.with_tcp_config(TcpConfig::default());
Source

pub fn udp_timeout(&mut self, timeout: Duration) -> &mut Self

Set the UDP connection timeout.

§Arguments
  • timeout - The timeout duration for UDP connections
§Examples
use ipstack::IpStackConfig;
use std::time::Duration;

let mut config = IpStackConfig::default();
config.udp_timeout(Duration::from_secs(60));
Source

pub fn mtu(&mut self, mtu: u16) -> Result<&mut Self, IpStackError>

Set the Maximum Transmission Unit (MTU) size.

§Arguments
  • mtu - The MTU size in bytes
§Examples
use ipstack::IpStackConfig;

let mut config = IpStackConfig::default();
config.mtu(1500).expect("Failed to set MTU");
Source

pub fn mtu_unchecked(&mut self, mtu: u16) -> &mut Self

Set the Maximum Transmission Unit (MTU) size without validation.

Source

pub fn packet_information(&mut self, packet_information: bool) -> &mut Self

Enable or disable packet information headers (Unix platforms only).

When enabled on Unix platforms, the TUN device will include 4-byte packet information headers.

§Arguments
  • packet_information - Whether to include packet information headers
§Examples
use ipstack::IpStackConfig;

let mut config = IpStackConfig::default();
config.packet_information(true);

Trait Implementations§

Source§

impl Default for IpStackConfig

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, 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.