Struct Adapter

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

Representation of a wireGuard adapter with safe idiomatic bindings to the functionality provided by the WireGuard* C functions.

The Adapter::create and Adapter::open functions serve as the entry point to using wireguard functionality

Wrapper around a WIREGUARD_ADAPTER_HANDLE

Related functions from WireGuardXXX are functions with an adapter self parameter

Implementations§

Source§

impl Adapter

Source

pub fn create( wireguard: &Wireguard, pool: &str, name: &str, guid: Option<u128>, ) -> Result<Adapter>

Creates a new wireguard adapter inside the pool pool with name name

Optionally a GUID can be specified that will become the GUID of this adapter once created.

Source

pub fn open(wireguard: &Wireguard, name: &str) -> Result<Adapter>

Attempts to open an existing wireguard with name name.

Source

pub fn set_config(&self, config: &SetInterface) -> Result<()>

Sets the wireguard configuration of this adapter

Source

pub fn set_default_route( &self, interface_addrs: &[IpNet], config: &SetInterface, ) -> Result<()>

Assigns this adapter an ip address and adds route(s) so that packets sent within the interface_addr ipnet will be sent across the WireGuard VPN

Source

pub fn set_route_with_metric( &self, interface_addrs: &[IpNet], config: &SetInterface, metric: u32, ) -> Result<()>

Assigns this adapter an ip address and adds route(s) so that packets sent within the interface_addr ipnet will be sent across the WireGuard VPN if no route with lower metric (higher priority) is found

Source

pub fn is_up(&self) -> Result<bool>

Get the state of this adapter

Source

pub fn up(&self) -> Result<()>

Puts this adapter into the up state

Source

pub fn down(&self) -> Result<()>

Puts this adapter into the down state

Source

pub fn get_luid(&self) -> u64

Returns the adapter’s LUID. This is a 64bit unique identifier that windows uses when referencing this adapter

Source

pub fn set_logging(&self, level: AdapterLoggingLevel) -> bool

Sets the logging level of this adapter

Log messages will be sent to the current logger (set using crate::set_logger

Source

pub fn get_config(&self) -> WireguardInterface

Gets the current configuration of this adapter

Trait Implementations§

Source§

impl Drop for Adapter

Source§

fn drop(&mut self)

Executes the destructor for this 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.