Struct wgctrl_rs::DeviceInfo [−][src]
pub struct DeviceInfo { pub name: String, pub public_key: Option<Key>, pub private_key: Option<Key>, pub fwmark: Option<u32>, pub listen_port: Option<u16>, pub peers: Vec<PeerInfo>, // some fields omitted }
Represents all available information about a WireGuard device (interface).
This struct contains the current configuration of the device
and the current configuration and state of all of its peers.
The peer statistics are retrieved once at construction time,
and need to be updated manually by calling get_by_name
.
Fields
name: String
The interface name of this device
public_key: Option<Key>
The public encryption key of this interface (if present)
private_key: Option<Key>
The private encryption key of this interface (if present)
fwmark: Option<u32>
The fwmark of this interface
listen_port: Option<u16>
The port to listen for incoming connections on
peers: Vec<PeerInfo>
The list of all registered peers and their information
Methods
impl DeviceInfo
[src]
impl DeviceInfo
pub fn enumerate() -> Result<Vec<String>, Error>
[src]
pub fn enumerate() -> Result<Vec<String>, Error>
Enumerates all WireGuard interfaces currently present in the system and returns their names.
You can use get_by_name
to retrieve more
detailed information on each interface.
Example
for dev in DeviceInfo::enumerate()? { println!("{:#?}", DeviceInfo::get_by_name(&dev)); }
pub fn get_by_name(name: &str) -> Result<Self, Error>
[src]
pub fn get_by_name(name: &str) -> Result<Self, Error>
Loads all available information on a given interface (by name) from the kernel.
Actually doing this probably requires root privileges.
Example
for dev in DeviceInfo::enumerate()? { if let Ok(dev) = DeviceInfo::get_by_name(&dev) { println!( "Successfully loaded interface {}; public key: {:?}", dev.name, dev.public_key.map(|k| k.to_base64()) ) } }
Trait Implementations
impl Debug for DeviceInfo
[src]
impl Debug for DeviceInfo
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for DeviceInfo
[src]
impl PartialEq for DeviceInfo
fn eq(&self, other: &DeviceInfo) -> bool
[src]
fn eq(&self, other: &DeviceInfo) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &DeviceInfo) -> bool
[src]
fn ne(&self, other: &DeviceInfo) -> bool
This method tests for !=
.
impl Eq for DeviceInfo
[src]
impl Eq for DeviceInfo
impl Clone for DeviceInfo
[src]
impl Clone for DeviceInfo
fn clone(&self) -> DeviceInfo
[src]
fn clone(&self) -> DeviceInfo
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a> From<&'a wg_device> for DeviceInfo
[src]
impl<'a> From<&'a wg_device> for DeviceInfo
fn from(raw: &wg_device) -> DeviceInfo
[src]
fn from(raw: &wg_device) -> DeviceInfo
Performs the conversion.
Auto Trait Implementations
impl Send for DeviceInfo
impl Send for DeviceInfo
impl Sync for DeviceInfo
impl Sync for DeviceInfo