Struct tun_rs::async::AsyncDevice

source ·
pub struct AsyncDevice { /* private fields */ }
Expand description

An async TUN device wrapper around a TUN device.

Implementations§

source§

impl AsyncDevice

source

pub fn new(device: Device) -> Result<AsyncDevice>

Create a new AsyncDevice wrapping around a Device.

source

pub unsafe fn from_fd(fd: RawFd) -> Result<AsyncDevice>

§Safety

This method is safe if the provided fd is valid Construct a AsyncDevice from an existing file descriptor

source

pub async fn recv(&self, buf: &mut [u8]) -> Result<usize>

Recv a packet from tun device

source

pub async fn send(&self, buf: &[u8]) -> Result<usize>

Send a packet to tun device

Trait Implementations§

source§

impl AbstractDevice for AsyncDevice

source§

fn name(&self) -> Result<String>

Get the device tun name.
source§

fn set_name(&self, name: &str) -> Result<()>

Set the device tun name.
source§

fn enabled(&self, value: bool) -> Result<()>

Turn on or off the interface.
source§

fn address(&self) -> Result<IpAddr>

Get the address.
source§

fn destination(&self) -> Result<IpAddr>

Get the destination address.
source§

fn broadcast(&self) -> Result<IpAddr>

Get the broadcast address.
source§

fn set_broadcast<A: IntoAddress>(&self, value: A) -> Result<()>

Set the broadcast address.
source§

fn netmask(&self) -> Result<IpAddr>

Get the netmask.
source§

fn set_network_address<A: IntoAddress>( &self, address: A, netmask: A, destination: Option<A>, ) -> Result<()>

Sets the network addresses of this adapter, including network address, subnet mask, and gateway
source§

fn mtu(&self) -> Result<u16>

Get the MTU.
source§

fn set_mtu(&self, value: u16) -> Result<()>

Set the MTU.
source§

fn set_mac_address(&self, eth_addr: [u8; 6]) -> Result<()>

Set mac address
source§

fn get_mac_address(&self) -> Result<[u8; 6]>

Get mac address
source§

impl FromRawFd for AsyncDevice

source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor. 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.