diff --git a/etherparse/src/link/ethernet2_header_slice.rs b/etherparse/src/link/ethernet2_header_slice.rs index 17d51915..8a26f27f 100644 --- a/etherparse/src/link/ethernet2_header_slice.rs +++ b/etherparse/src/link/ethernet2_header_slice.rs @@ -43,7 +43,7 @@ impl<'a> Ethernet2HeaderSlice<'a> { /// [`Ethernet2Header::LEN`] #[inline] #[cfg(feature = "std")] - pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ethernet2HeaderSlice { + pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ethernet2HeaderSlice<'_> { debug_assert!(slice.len() == Ethernet2Header::LEN); Ethernet2HeaderSlice { slice } } diff --git a/etherparse/src/link/linux_sll_header_slice.rs b/etherparse/src/link/linux_sll_header_slice.rs index dbf96da7..4ae73152 100644 --- a/etherparse/src/link/linux_sll_header_slice.rs +++ b/etherparse/src/link/linux_sll_header_slice.rs @@ -72,7 +72,7 @@ impl<'a> LinuxSllHeaderSlice<'a> { /// [`LinuxSllHeader::LEN`] and the fields are valid #[inline] #[cfg(feature = "std")] - pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> LinuxSllHeaderSlice { + pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> LinuxSllHeaderSlice<'_> { debug_assert!(slice.len() == LinuxSllHeader::LEN); LinuxSllHeaderSlice { slice } } diff --git a/etherparse/src/link/single_vlan_header_slice.rs b/etherparse/src/link/single_vlan_header_slice.rs index 2406cc6d..e25ca572 100644 --- a/etherparse/src/link/single_vlan_header_slice.rs +++ b/etherparse/src/link/single_vlan_header_slice.rs @@ -43,7 +43,7 @@ impl<'a> SingleVlanHeaderSlice<'a> { /// The caller must ensured that the given slice has the length of /// [`SingleVlanHeader::LEN`] #[inline] - pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> SingleVlanHeaderSlice { + pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> SingleVlanHeaderSlice<'_> { SingleVlanHeaderSlice { slice } } diff --git a/etherparse/src/net/ip_slice.rs b/etherparse/src/net/ip_slice.rs index 5c7eb5f5..2d7f594f 100644 --- a/etherparse/src/net/ip_slice.rs +++ b/etherparse/src/net/ip_slice.rs @@ -15,7 +15,7 @@ pub enum IpSlice<'a> { impl<'a> IpSlice<'a> { /// Returns a reference to the `Ipv4Slice` if `self` is a `IpSlice::Ipv4`. - pub fn ipv4(&self) -> Option<&Ipv4Slice> { + pub fn ipv4(&self) -> Option<&Ipv4Slice<'_>> { use IpSlice::*; match self { Ipv4(slice) => Some(slice), @@ -24,7 +24,7 @@ impl<'a> IpSlice<'a> { } /// Returns a reference to the `Ipv6Slice` if `self` is a `IpSlice::Ipv6`. - pub fn ipv6(&self) -> Option<&Ipv6Slice> { + pub fn ipv6(&self) -> Option<&Ipv6Slice<'_>> { use IpSlice::*; match self { Ipv4(_) => None, @@ -83,7 +83,7 @@ impl<'a> IpSlice<'a> { /// Separates and validates IP headers (including extension headers) /// in the given slice and determine the sub-slice containing the payload /// of the IP packet. - pub fn from_slice(slice: &[u8]) -> Result { + pub fn from_slice(slice: &[u8]) -> Result, err::ip::SliceError> { use crate::ip_number::AUTH; use err::ip::{HeaderError::*, HeadersError::*, SliceError::*}; use IpSlice::*; diff --git a/etherparse/src/net/ipv4_header_slice.rs b/etherparse/src/net/ipv4_header_slice.rs index 1dcf250d..74aaef08 100644 --- a/etherparse/src/net/ipv4_header_slice.rs +++ b/etherparse/src/net/ipv4_header_slice.rs @@ -89,7 +89,7 @@ impl<'a> Ipv4HeaderSlice<'a> { /// It must ensured that the slice exactly contains the IPv4 header /// and the ihl (intra header length) & total length must be consistent. #[inline] - pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv4HeaderSlice { + pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv4HeaderSlice<'_> { Ipv4HeaderSlice { slice } } diff --git a/etherparse/src/net/ipv4_options.rs b/etherparse/src/net/ipv4_options.rs index f741a072..6518d4c3 100644 --- a/etherparse/src/net/ipv4_options.rs +++ b/etherparse/src/net/ipv4_options.rs @@ -141,7 +141,7 @@ impl core::hash::Hash for Ipv4Options { impl core::cmp::PartialOrd for Ipv4Options { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.as_slice().cmp(other.as_slice())) + Some(self.cmp(other)) } } diff --git a/etherparse/src/net/ipv4_slice.rs b/etherparse/src/net/ipv4_slice.rs index e22a566a..913ab5ce 100644 --- a/etherparse/src/net/ipv4_slice.rs +++ b/etherparse/src/net/ipv4_slice.rs @@ -22,7 +22,7 @@ impl<'a> Ipv4Slice<'a> { /// /// If you want to ignore these kind of length errors based on the length /// fields in the IP headers use [`crate::LaxIpv4Slice::from_slice`] instead. - pub fn from_slice(slice: &[u8]) -> Result { + pub fn from_slice(slice: &[u8]) -> Result, SliceError> { use crate::ip_number::AUTH; // decode the header @@ -118,13 +118,13 @@ impl<'a> Ipv4Slice<'a> { /// Returns a slice containing the IPv4 header. #[inline] - pub fn header(&self) -> Ipv4HeaderSlice { + pub fn header(&self) -> Ipv4HeaderSlice<'_> { self.header } /// Returns a slice containing the IPv4 extension headers. #[inline] - pub fn extensions(&self) -> Ipv4ExtensionsSlice { + pub fn extensions(&self) -> Ipv4ExtensionsSlice<'_> { self.exts } diff --git a/etherparse/src/net/ipv6_header_slice.rs b/etherparse/src/net/ipv6_header_slice.rs index fef8b05e..ce54d5c8 100644 --- a/etherparse/src/net/ipv6_header_slice.rs +++ b/etherparse/src/net/ipv6_header_slice.rs @@ -56,7 +56,7 @@ impl<'a> Ipv6HeaderSlice<'a> { /// /// It must ensured that the slice length is at least [`Ipv6Header::LEN`]. #[inline] - pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv6HeaderSlice { + pub(crate) unsafe fn from_slice_unchecked(slice: &[u8]) -> Ipv6HeaderSlice<'_> { Ipv6HeaderSlice { slice } } diff --git a/etherparse/src/net/lax_ip_slice.rs b/etherparse/src/net/lax_ip_slice.rs index 928102ee..e189bf1a 100644 --- a/etherparse/src/net/lax_ip_slice.rs +++ b/etherparse/src/net/lax_ip_slice.rs @@ -24,7 +24,7 @@ pub enum LaxIpSlice<'a> { impl<'a> LaxIpSlice<'a> { /// Returns a reference to the `Ipv4Slice` if `self` is a `IpSlice::Ipv4`. - pub fn ipv4(&self) -> Option<&LaxIpv4Slice> { + pub fn ipv4(&self) -> Option<&LaxIpv4Slice<'_>> { use LaxIpSlice::*; match self { Ipv4(slice) => Some(slice), @@ -33,7 +33,7 @@ impl<'a> LaxIpSlice<'a> { } /// Returns a reference to the `Ipv6Slice` if `self` is a `IpSlice::Ipv6`. - pub fn ipv6(&self) -> Option<&LaxIpv6Slice> { + pub fn ipv6(&self) -> Option<&LaxIpv6Slice<'_>> { use LaxIpSlice::*; match self { Ipv4(_) => None, @@ -141,7 +141,7 @@ impl<'a> LaxIpSlice<'a> { slice: &[u8], ) -> Result< ( - LaxIpSlice, + LaxIpSlice<'_>, Option<(err::ipv6_exts::HeaderSliceError, err::Layer)>, ), err::ip::LaxHeaderSliceError, diff --git a/etherparse/src/net/lax_ipv4_slice.rs b/etherparse/src/net/lax_ipv4_slice.rs index a9082da0..04ba77d9 100644 --- a/etherparse/src/net/lax_ipv4_slice.rs +++ b/etherparse/src/net/lax_ipv4_slice.rs @@ -70,8 +70,10 @@ impl<'a> LaxIpv4Slice<'a> { /// is set to [`LenSource::Ipv4HeaderTotalLen`]. pub fn from_slice( slice: &[u8], - ) -> Result<(LaxIpv4Slice, Option), err::ipv4::HeaderSliceError> - { + ) -> Result< + (LaxIpv4Slice<'_>, Option), + err::ipv4::HeaderSliceError, + > { use crate::ip_number::AUTH; // decode the header @@ -197,13 +199,13 @@ impl<'a> LaxIpv4Slice<'a> { /// Returns a slice containing the IPv4 header. #[inline] - pub fn header(&self) -> Ipv4HeaderSlice { + pub fn header(&self) -> Ipv4HeaderSlice<'_> { self.header } /// Returns a slice containing the IPv4 extension headers. #[inline] - pub fn extensions(&self) -> Ipv4ExtensionsSlice { + pub fn extensions(&self) -> Ipv4ExtensionsSlice<'_> { self.exts } diff --git a/etherparse/src/net/net_slice.rs b/etherparse/src/net/net_slice.rs index f7d20f72..7952bea5 100644 --- a/etherparse/src/net/net_slice.rs +++ b/etherparse/src/net/net_slice.rs @@ -70,7 +70,7 @@ impl<'a> NetSlice<'a> { /// Returns references to the ARP packet slice if the slice contains an ARP values. #[inline] - pub fn arp_ref(&self) -> Option<&ArpPacketSlice> { + pub fn arp_ref(&self) -> Option<&ArpPacketSlice<'_>> { if let NetSlice::Arp(arp) = self { Some(arp) } else { diff --git a/etherparse/src/packet_headers.rs b/etherparse/src/packet_headers.rs index 4aa4e98f..84fd8c7b 100644 --- a/etherparse/src/packet_headers.rs +++ b/etherparse/src/packet_headers.rs @@ -360,7 +360,7 @@ impl<'a> PacketHeaders<'a> { /// } /// } /// ``` - pub fn from_ip_slice(slice: &[u8]) -> Result { + pub fn from_ip_slice(slice: &[u8]) -> Result, err::packet::SliceError> { use err::packet::SliceError::*; // read ip headers diff --git a/etherparse/src/transport/tcp_header.rs b/etherparse/src/transport/tcp_header.rs index a26ce532..6313fc18 100644 --- a/etherparse/src/transport/tcp_header.rs +++ b/etherparse/src/transport/tcp_header.rs @@ -202,7 +202,7 @@ impl TcpHeader { /// Returns an iterator that allows to iterate through all /// known TCP header options. #[inline] - pub fn options_iterator(&self) -> TcpOptionsIterator { + pub fn options_iterator(&self) -> TcpOptionsIterator<'_> { self.options.elements_iter() } diff --git a/etherparse/src/transport/tcp_header_slice.rs b/etherparse/src/transport/tcp_header_slice.rs index 01889d4d..6bcecf7b 100644 --- a/etherparse/src/transport/tcp_header_slice.rs +++ b/etherparse/src/transport/tcp_header_slice.rs @@ -281,7 +281,7 @@ impl<'a> TcpHeaderSlice<'a> { /// Returns an iterator that allows to iterate through all known TCP header options. #[inline] - pub fn options_iterator(&self) -> TcpOptionsIterator { + pub fn options_iterator(&self) -> TcpOptionsIterator<'_> { TcpOptionsIterator::from_slice(self.options()) } diff --git a/etherparse/src/transport/tcp_options.rs b/etherparse/src/transport/tcp_options.rs index 8c2720b0..43da9f62 100644 --- a/etherparse/src/transport/tcp_options.rs +++ b/etherparse/src/transport/tcp_options.rs @@ -456,7 +456,7 @@ impl TcpOptions { /// assert_eq!(v, vec![Ok(WindowScale(123)), Ok(Noop), Ok(Noop)]); /// ``` #[inline] - pub fn elements_iter(&self) -> TcpOptionsIterator { + pub fn elements_iter(&self) -> TcpOptionsIterator<'_> { TcpOptionsIterator { options: self.as_slice(), } @@ -512,7 +512,7 @@ impl core::hash::Hash for TcpOptions { impl core::cmp::PartialOrd for TcpOptions { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.as_slice().cmp(other.as_slice())) + Some(self.cmp(other)) } } diff --git a/etherparse/src/transport/tcp_slice.rs b/etherparse/src/transport/tcp_slice.rs index f25479f4..fcde9e39 100644 --- a/etherparse/src/transport/tcp_slice.rs +++ b/etherparse/src/transport/tcp_slice.rs @@ -309,7 +309,7 @@ impl<'a> TcpSlice<'a> { /// Returns an iterator that allows to iterate through all known TCP header options. #[inline] - pub fn options_iterator(&self) -> TcpOptionsIterator { + pub fn options_iterator(&self) -> TcpOptionsIterator<'_> { TcpOptionsIterator::from_slice(self.options()) }