Fix clippy 1.83 warnings (elite lifetimes, use non_exhaustive)

pull/326/head
Matěj Laitl 2024-12-05 21:46:37 +01:00
parent b2e414984e
commit c9ead42108
6 changed files with 7 additions and 13 deletions

View File

@ -36,7 +36,7 @@ pub enum ServerError {
Hyper(#[from] hyper::Error),
}
impl<'a> From<&'a ServerError> for StatusCode {
impl From<&ServerError> for StatusCode {
fn from(error: &ServerError) -> StatusCode {
use ServerError::*;
match error {

View File

@ -110,7 +110,7 @@ impl<'de> Deserialize<'de> for Endpoint {
D: serde::Deserializer<'de>,
{
struct EndpointVisitor;
impl<'de> serde::de::Visitor<'de> for EndpointVisitor {
impl serde::de::Visitor<'_> for EndpointVisitor {
type Value = Endpoint;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -238,7 +238,7 @@ pub struct CidrTree<'a> {
contents: &'a Cidr,
}
impl<'a> std::ops::Deref for CidrTree<'a> {
impl std::ops::Deref for CidrTree<'_> {
type Target = Cidr;
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 {
PeerDiff::new(None, Some(peer))
.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,
/// hopefully minimizing dropped packets and other interruptions.
fn from(diff: PeerDiff) -> Self {

View File

@ -118,7 +118,6 @@ impl TryFrom<WgPeer> for PeerInfo {
endpoint,
persistent_keepalive_interval,
allowed_ips,
__cant_construct_me: (),
},
stats: PeerStats {
last_handshake_time,
@ -158,7 +157,6 @@ impl<'a> TryFrom<&'a [WgDeviceAttrs]> for Device {
peers,
linked_name: None,
backend: Backend::Kernel,
__cant_construct_me: (),
})
}
}

View File

@ -86,7 +86,6 @@ fn new_peer_info(public_key: Key) -> PeerInfo {
endpoint: None,
persistent_keepalive_interval: None,
allowed_ips: vec![],
__cant_construct_me: (),
},
stats: PeerStats {
last_handshake_time: None,
@ -119,7 +118,6 @@ impl ConfigParser {
peers: vec![],
linked_name: resolve_tun(name).ok(),
backend: Backend::Userspace,
__cant_construct_me: (),
};
Self {

View File

@ -69,7 +69,6 @@ impl PeerConfigBuilder {
endpoint: self.endpoint,
persistent_keepalive_interval: self.persistent_keepalive_interval,
allowed_ips: self.allowed_ips,
__cant_construct_me: (),
}
}

View File

@ -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.
#[derive(Debug, PartialEq, Eq, Clone)]
#[non_exhaustive]
pub struct PeerConfig {
/// The public key of the peer.
pub public_key: Key,
@ -57,7 +58,6 @@ pub struct PeerConfig {
pub persistent_keepalive_interval: Option<u16>,
/// The IP addresses this peer is allowed to have.
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).
@ -91,6 +91,7 @@ pub struct PeerInfo {
/// The peer statistics are retrieved once at construction time,
/// and need to be updated manually by calling [`get_by_name`](DeviceInfo::get_by_name).
#[derive(Debug, PartialEq, Eq, Clone)]
#[non_exhaustive]
pub struct Device {
/// The interface name of this device
pub name: InterfaceName,
@ -108,8 +109,6 @@ pub struct Device {
pub linked_name: Option<String>,
/// The backend the device exists on (userspace or kernel).
pub backend: Backend,
pub(crate) __cant_construct_me: (),
}
type RawInterfaceName = [c_char; libc::IFNAMSIZ];