Fix clippy 1.83 warnings (elite lifetimes, use non_exhaustive)
parent
b2e414984e
commit
c9ead42108
|
@ -36,7 +36,7 @@ pub enum ServerError {
|
||||||
Hyper(#[from] hyper::Error),
|
Hyper(#[from] hyper::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a ServerError> for StatusCode {
|
impl From<&ServerError> for StatusCode {
|
||||||
fn from(error: &ServerError) -> StatusCode {
|
fn from(error: &ServerError) -> StatusCode {
|
||||||
use ServerError::*;
|
use ServerError::*;
|
||||||
match error {
|
match error {
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl<'de> Deserialize<'de> for Endpoint {
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
struct EndpointVisitor;
|
struct EndpointVisitor;
|
||||||
impl<'de> serde::de::Visitor<'de> for EndpointVisitor {
|
impl serde::de::Visitor<'_> for EndpointVisitor {
|
||||||
type Value = Endpoint;
|
type Value = Endpoint;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
@ -238,7 +238,7 @@ pub struct CidrTree<'a> {
|
||||||
contents: &'a Cidr,
|
contents: &'a Cidr,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> std::ops::Deref for CidrTree<'a> {
|
impl std::ops::Deref for CidrTree<'_> {
|
||||||
type Target = Cidr;
|
type Target = Cidr;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
@ -718,7 +718,7 @@ impl<'a> PeerDiff<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a Peer> for PeerConfigBuilder {
|
impl From<&Peer> for PeerConfigBuilder {
|
||||||
fn from(peer: &Peer) -> Self {
|
fn from(peer: &Peer) -> Self {
|
||||||
PeerDiff::new(None, Some(peer))
|
PeerDiff::new(None, Some(peer))
|
||||||
.expect("No Err on explicitly set peer data")
|
.expect("No Err on explicitly set peer data")
|
||||||
|
@ -727,7 +727,7 @@ impl<'a> From<&'a Peer> for PeerConfigBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<PeerDiff<'a>> for PeerConfigBuilder {
|
impl From<PeerDiff<'_>> for PeerConfigBuilder {
|
||||||
/// Turn a PeerDiff into a minimal set of instructions to update the WireGuard interface,
|
/// Turn a PeerDiff into a minimal set of instructions to update the WireGuard interface,
|
||||||
/// hopefully minimizing dropped packets and other interruptions.
|
/// hopefully minimizing dropped packets and other interruptions.
|
||||||
fn from(diff: PeerDiff) -> Self {
|
fn from(diff: PeerDiff) -> Self {
|
||||||
|
|
|
@ -118,7 +118,6 @@ impl TryFrom<WgPeer> for PeerInfo {
|
||||||
endpoint,
|
endpoint,
|
||||||
persistent_keepalive_interval,
|
persistent_keepalive_interval,
|
||||||
allowed_ips,
|
allowed_ips,
|
||||||
__cant_construct_me: (),
|
|
||||||
},
|
},
|
||||||
stats: PeerStats {
|
stats: PeerStats {
|
||||||
last_handshake_time,
|
last_handshake_time,
|
||||||
|
@ -158,7 +157,6 @@ impl<'a> TryFrom<&'a [WgDeviceAttrs]> for Device {
|
||||||
peers,
|
peers,
|
||||||
linked_name: None,
|
linked_name: None,
|
||||||
backend: Backend::Kernel,
|
backend: Backend::Kernel,
|
||||||
__cant_construct_me: (),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,6 @@ fn new_peer_info(public_key: Key) -> PeerInfo {
|
||||||
endpoint: None,
|
endpoint: None,
|
||||||
persistent_keepalive_interval: None,
|
persistent_keepalive_interval: None,
|
||||||
allowed_ips: vec![],
|
allowed_ips: vec![],
|
||||||
__cant_construct_me: (),
|
|
||||||
},
|
},
|
||||||
stats: PeerStats {
|
stats: PeerStats {
|
||||||
last_handshake_time: None,
|
last_handshake_time: None,
|
||||||
|
@ -119,7 +118,6 @@ impl ConfigParser {
|
||||||
peers: vec![],
|
peers: vec![],
|
||||||
linked_name: resolve_tun(name).ok(),
|
linked_name: resolve_tun(name).ok(),
|
||||||
backend: Backend::Userspace,
|
backend: Backend::Userspace,
|
||||||
__cant_construct_me: (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -69,7 +69,6 @@ impl PeerConfigBuilder {
|
||||||
endpoint: self.endpoint,
|
endpoint: self.endpoint,
|
||||||
persistent_keepalive_interval: self.persistent_keepalive_interval,
|
persistent_keepalive_interval: self.persistent_keepalive_interval,
|
||||||
allowed_ips: self.allowed_ips,
|
allowed_ips: self.allowed_ips,
|
||||||
__cant_construct_me: (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ impl std::str::FromStr for AllowedIp {
|
||||||
///
|
///
|
||||||
/// These are the attributes that don't change over time and are part of the configuration.
|
/// These are the attributes that don't change over time and are part of the configuration.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct PeerConfig {
|
pub struct PeerConfig {
|
||||||
/// The public key of the peer.
|
/// The public key of the peer.
|
||||||
pub public_key: Key,
|
pub public_key: Key,
|
||||||
|
@ -57,7 +58,6 @@ pub struct PeerConfig {
|
||||||
pub persistent_keepalive_interval: Option<u16>,
|
pub persistent_keepalive_interval: Option<u16>,
|
||||||
/// The IP addresses this peer is allowed to have.
|
/// The IP addresses this peer is allowed to have.
|
||||||
pub allowed_ips: Vec<AllowedIp>,
|
pub allowed_ips: Vec<AllowedIp>,
|
||||||
pub(crate) __cant_construct_me: (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a single peer's current statistics (i.e. the data from the current session).
|
/// Represents a single peer's current statistics (i.e. the data from the current session).
|
||||||
|
@ -91,6 +91,7 @@ pub struct PeerInfo {
|
||||||
/// The peer statistics are retrieved once at construction time,
|
/// The peer statistics are retrieved once at construction time,
|
||||||
/// and need to be updated manually by calling [`get_by_name`](DeviceInfo::get_by_name).
|
/// and need to be updated manually by calling [`get_by_name`](DeviceInfo::get_by_name).
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
/// The interface name of this device
|
/// The interface name of this device
|
||||||
pub name: InterfaceName,
|
pub name: InterfaceName,
|
||||||
|
@ -108,8 +109,6 @@ pub struct Device {
|
||||||
pub linked_name: Option<String>,
|
pub linked_name: Option<String>,
|
||||||
/// The backend the device exists on (userspace or kernel).
|
/// The backend the device exists on (userspace or kernel).
|
||||||
pub backend: Backend,
|
pub backend: Backend,
|
||||||
|
|
||||||
pub(crate) __cant_construct_me: (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RawInterfaceName = [c_char; libc::IFNAMSIZ];
|
type RawInterfaceName = [c_char; libc::IFNAMSIZ];
|
||||||
|
|
Loading…
Reference in New Issue