tun

Struct Configuration

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

Configuration builder for a TUN interface.

Implementations§

Source§

impl Configuration

Source

pub fn platform_config<F>(&mut self, f: F) -> &mut Self
where F: FnOnce(&mut PlatformConfig),

Access the platform-dependent configuration.

Source

pub fn name<S: AsRef<str>>(&mut self, tun_name: S) -> &mut Self

👎Deprecated since 0.7.0: Since the API name may have an easy name conflict when IDE prompts, it is replaced by tun_name for better coding experience

Functionally equivalent to tun_name

Source

pub fn tun_name<S: AsRef<str>>(&mut self, tun_name: S) -> &mut Self

Set the tun name.

[Note: on macOS, the tun name must be the form utunx where x is a number, such as utun3. – end note]

Source

pub fn address<A: ToAddress>(&mut self, value: A) -> &mut Self

Set the address.

Source

pub fn destination<A: ToAddress>(&mut self, value: A) -> &mut Self

Set the destination address.

Source

pub fn broadcast<A: ToAddress>(&mut self, value: A) -> &mut Self

Set the broadcast address.

Source

pub fn netmask<A: ToAddress>(&mut self, value: A) -> &mut Self

Set the netmask.

Source

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

Set the MTU.

Source

pub fn up(&mut self) -> &mut Self

Set the interface to be enabled once created.

Source

pub fn down(&mut self) -> &mut Self

Set the interface to be disabled once created.

Source

pub fn layer(&mut self, value: Layer) -> &mut Self

Set the OSI layer of operation.

Source

pub fn queues(&mut self, value: usize) -> &mut Self

👎Deprecated since 0.7.0: The queues will always be 1.

Set the number of queues. Note: The queues must be 1, otherwise will failed.

Source

pub fn raw_fd(&mut self, fd: i32) -> &mut Self

Source

pub fn raw_handle(&mut self, handle: HANDLE) -> &mut Self

Source

pub fn ring_capacity(&mut self, ring_capacity: u32) -> &mut Self

Source

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

Trait Implementations§

Source§

impl Clone for Configuration

Source§

fn clone(&self) -> Configuration

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Configuration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Configuration

Source§

fn default() -> Configuration

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.