Skip to content

Commit 014233d

Browse files
committed
Fix (nightly) clippy warnings: explicit lifetime could be elided
1 parent a937bd5 commit 014233d

14 files changed

+35
-35
lines changed

src/data/pcap_nflog.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn parse_nflog_header(i: &[u8]) -> IResult<&[u8], NflogHdr> {
100100
Ok((i, NflogHdr { af, vers, res_id }))
101101
}
102102

103-
impl<'a> NflogPacket<'a> {
103+
impl NflogPacket<'_> {
104104
pub fn get(&self, attr: NfAttrType) -> Option<&NflogTlv> {
105105
self.data.iter().find(|v| v.t == attr as u16)
106106
}

src/pcap/capture.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct LegacyPcapSlice<'a> {
3737
rem: &'a [u8],
3838
}
3939

40-
impl<'a> LegacyPcapSlice<'a> {
40+
impl LegacyPcapSlice<'_> {
4141
pub fn from_slice(i: &[u8]) -> Result<LegacyPcapSlice, nom::Err<PcapError<&[u8]>>> {
4242
let (rem, header) = parse_pcap_header(i)?;
4343
Ok(LegacyPcapSlice { header, rem })
@@ -68,7 +68,7 @@ pub struct PcapCapture<'a> {
6868
pub blocks: Vec<LegacyPcapBlock<'a>>,
6969
}
7070

71-
impl<'a> PcapCapture<'a> {
71+
impl PcapCapture<'_> {
7272
pub fn from_file(i: &[u8]) -> Result<PcapCapture, PcapError<&[u8]>> {
7373
match parse_pcap(i) {
7474
Ok((_, pcap)) => Ok(pcap),
@@ -79,7 +79,7 @@ impl<'a> PcapCapture<'a> {
7979
}
8080
}
8181

82-
impl<'a> fmt::Debug for PcapCapture<'a> {
82+
impl fmt::Debug for PcapCapture<'_> {
8383
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
8484
writeln!(f, "PcapCapture:")
8585
}
@@ -102,7 +102,7 @@ impl<'a> Iterator for LegacyPcapIterator<'a> {
102102
}
103103
}
104104

105-
impl<'a> Capture for PcapCapture<'a> {
105+
impl Capture for PcapCapture<'_> {
106106
fn get_datalink(&self) -> Linktype {
107107
self.header.network
108108
}

src/pcapng/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum Block<'a> {
2525
Unknown(UnknownBlock<'a>),
2626
}
2727

28-
impl<'a> Block<'a> {
28+
impl Block<'_> {
2929
/// Returns true if blocks contains a network packet
3030
pub fn is_data_block(&self) -> bool {
3131
matches!(self, &Block::EnhancedPacket(_) | &Block::SimplePacket(_))

src/pcapng/capture.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct PcapNGSlice<'a> {
3333
rem: &'a [u8],
3434
}
3535

36-
impl<'a> PcapNGSlice<'a> {
36+
impl PcapNGSlice<'_> {
3737
pub fn from_slice(i: &[u8]) -> Result<PcapNGSlice, nom::Err<PcapError<&[u8]>>> {
3838
// just check that first block is a valid one
3939
let (_rem, _shb) = parse_sectionheaderblock(i)?;
@@ -73,7 +73,7 @@ pub struct PcapNGCapture<'a> {
7373
pub sections: Vec<Section<'a>>,
7474
}
7575

76-
impl<'a> fmt::Debug for PcapNGCapture<'a> {
76+
impl fmt::Debug for PcapNGCapture<'_> {
7777
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
7878
writeln!(f, "PcapNGCapture:")
7979
}

src/pcapng/custom.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'a, En: PcapEndianness> PcapNGBlockParser<'a, En, CustomBlock<'a>> for DCBP
6464
}
6565
}
6666

67-
impl<'a> CustomBlock<'a> {
67+
impl CustomBlock<'_> {
6868
pub fn do_not_copy(&self) -> bool {
6969
self.block_type == DCB_MAGIC || self.block_type == DCB_MAGIC.swap_bytes()
7070
}

src/pcapng/enhanced_packet.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct EnhancedPacketBlock<'a> {
5252
pub block_len2: u32,
5353
}
5454

55-
impl<'a> EnhancedPacketBlock<'a> {
55+
impl EnhancedPacketBlock<'_> {
5656
/// Decode the packet timestamp
5757
///
5858
/// To decode the timestamp, the raw values if_tsresol and if_tsoffset are required.
@@ -76,7 +76,7 @@ impl<'a> EnhancedPacketBlock<'a> {
7676
}
7777
}
7878

79-
impl<'a> PcapNGPacketBlock for EnhancedPacketBlock<'a> {
79+
impl PcapNGPacketBlock for EnhancedPacketBlock<'_> {
8080
fn big_endian(&self) -> bool {
8181
self.block_type != EPB_MAGIC
8282
}

src/pcapng/interface_description.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct InterfaceDescriptionBlock<'a> {
2323
pub if_tsoffset: i64,
2424
}
2525

26-
impl<'a> InterfaceDescriptionBlock<'a> {
26+
impl InterfaceDescriptionBlock<'_> {
2727
/// Decode the interface time resolution, in units per second
2828
///
2929
/// Return the resolution, or `None` if the resolution is invalid (for ex. greater than `2^64`)

src/pcapng/interface_statistics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct InterfaceStatisticsBlock<'a> {
1717
pub block_len2: u32,
1818
}
1919

20-
impl<'a> InterfaceStatisticsBlock<'a> {
20+
impl InterfaceStatisticsBlock<'_> {
2121
/// Return the `isb_starttime` option value, if present
2222
///
2323
/// The returned value is `(ts_high,ts_low)`. To convert to a full timestamp,

src/pcapng/name_resolution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct NameRecord<'a> {
2727
pub record_value: &'a [u8],
2828
}
2929

30-
impl<'a> NameRecord<'a> {
30+
impl NameRecord<'_> {
3131
pub const END: NameRecord<'static> = NameRecord {
3232
record_type: NameRecordType::End,
3333
record_value: &[],

src/pcapng/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub struct PcapNGOption<'a> {
8080
pub value: Cow<'a, [u8]>,
8181
}
8282

83-
impl<'a> PcapNGOption<'a> {
83+
impl PcapNGOption<'_> {
8484
/// Return a reference to the option value, as raw bytes (not related to the `len` field)
8585
#[inline]
8686
pub fn value(&self) -> &[u8] {

src/pcapng/section_header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct SectionHeaderBlock<'a> {
2727
pub block_len2: u32,
2828
}
2929

30-
impl<'a> SectionHeaderBlock<'a> {
30+
impl SectionHeaderBlock<'_> {
3131
pub fn big_endian(&self) -> bool {
3232
self.bom != BOM_MAGIC
3333
}

src/pcapng/simple_packet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub struct SimplePacketBlock<'a> {
2525
pub block_len2: u32,
2626
}
2727

28-
impl<'a> PcapNGPacketBlock for SimplePacketBlock<'a> {
28+
impl PcapNGPacketBlock for SimplePacketBlock<'_> {
2929
fn big_endian(&self) -> bool {
3030
self.block_type != SPB_MAGIC
3131
}

src/serialize.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ToVec for PcapHeader {
4545
}
4646
}
4747

48-
impl<'a> ToVec for LegacyPcapBlock<'a> {
48+
impl ToVec for LegacyPcapBlock<'_> {
4949
fn to_vec_raw(&self) -> Result<Vec<u8>, GenError> {
5050
let mut v = Vec::with_capacity(self.data.len() + 16);
5151

@@ -73,7 +73,7 @@ fn padding_for<'a, W: Write + 'a>(unaligned_length: u32) -> impl SerializeFn<W>
7373
})
7474
}
7575

76-
impl<'a> ToVec for PcapNGOption<'a> {
76+
impl ToVec for PcapNGOption<'_> {
7777
fn to_vec_raw(&self) -> Result<Vec<u8>, GenError> {
7878
let mut v = Vec::new();
7979
gen(pcapngoption_le(self), &mut v).map(|res| res.0.to_vec())
@@ -106,7 +106,7 @@ fn fix_options(options: &mut Vec<PcapNGOption>) {
106106
}
107107
}
108108

109-
impl<'a> ToVec for SectionHeaderBlock<'a> {
109+
impl ToVec for SectionHeaderBlock<'_> {
110110
/// Check and correct all fields: use magic, version and fix lengths fields
111111
fn fix(&mut self) {
112112
self.block_type = SHB_MAGIC;
@@ -140,7 +140,7 @@ impl<'a> ToVec for SectionHeaderBlock<'a> {
140140
}
141141
}
142142

143-
impl<'a> ToVec for InterfaceDescriptionBlock<'a> {
143+
impl ToVec for InterfaceDescriptionBlock<'_> {
144144
/// Check and correct all fields: use magic, set time resolution and fix lengths fields
145145
fn fix(&mut self) {
146146
self.block_type = IDB_MAGIC;
@@ -192,7 +192,7 @@ impl<'a> ToVec for InterfaceDescriptionBlock<'a> {
192192
}
193193
}
194194

195-
impl<'a> ToVec for EnhancedPacketBlock<'a> {
195+
impl ToVec for EnhancedPacketBlock<'_> {
196196
/// Check and correct all fields: use magic, version and fix lengths fields
197197
fn fix(&mut self) {
198198
self.block_type = EPB_MAGIC;
@@ -225,7 +225,7 @@ impl<'a> ToVec for EnhancedPacketBlock<'a> {
225225
}
226226
}
227227

228-
impl<'a> ToVec for SimplePacketBlock<'a> {
228+
impl ToVec for SimplePacketBlock<'_> {
229229
fn fix(&mut self) {
230230
self.block_type = SPB_MAGIC;
231231
// fix length
@@ -262,7 +262,7 @@ fn namerecords_length(nr: &[NameRecord]) -> usize {
262262
nr.iter().map(|n| align32!(2 + n.record_value.len())).sum()
263263
}
264264

265-
impl<'a> ToVec for NameResolutionBlock<'a> {
265+
impl ToVec for NameResolutionBlock<'_> {
266266
fn fix(&mut self) {
267267
self.block_type = NRB_MAGIC;
268268
fix_options(&mut self.options);
@@ -288,7 +288,7 @@ impl<'a> ToVec for NameResolutionBlock<'a> {
288288
}
289289
}
290290

291-
impl<'a> ToVec for InterfaceStatisticsBlock<'a> {
291+
impl ToVec for InterfaceStatisticsBlock<'_> {
292292
fn fix(&mut self) {
293293
self.block_type = ISB_MAGIC;
294294
fix_options(&mut self.options);
@@ -315,7 +315,7 @@ impl<'a> ToVec for InterfaceStatisticsBlock<'a> {
315315
}
316316
}
317317

318-
impl<'a> ToVec for SystemdJournalExportBlock<'a> {
318+
impl ToVec for SystemdJournalExportBlock<'_> {
319319
fn fix(&mut self) {
320320
if self.block_type != SJE_MAGIC {
321321
self.block_type = SJE_MAGIC;
@@ -341,7 +341,7 @@ impl<'a> ToVec for SystemdJournalExportBlock<'a> {
341341
}
342342
}
343343

344-
impl<'a> ToVec for DecryptionSecretsBlock<'a> {
344+
impl ToVec for DecryptionSecretsBlock<'_> {
345345
fn fix(&mut self) {
346346
if self.block_type != DSB_MAGIC {
347347
self.block_type = DSB_MAGIC;
@@ -372,7 +372,7 @@ impl<'a> ToVec for DecryptionSecretsBlock<'a> {
372372
}
373373
}
374374

375-
impl<'a> ToVec for ProcessInformationBlock<'a> {
375+
impl ToVec for ProcessInformationBlock<'_> {
376376
/// Check and correct all fields: use magic, version and fix lengths fields
377377
fn fix(&mut self) {
378378
self.block_type = PIB_MAGIC;
@@ -399,7 +399,7 @@ impl<'a> ToVec for ProcessInformationBlock<'a> {
399399
}
400400
}
401401

402-
impl<'a> ToVec for CustomBlock<'a> {
402+
impl ToVec for CustomBlock<'_> {
403403
fn fix(&mut self) {
404404
if self.block_type != DCB_MAGIC && self.block_type != CB_MAGIC {
405405
self.block_type = CB_MAGIC;
@@ -426,7 +426,7 @@ impl<'a> ToVec for CustomBlock<'a> {
426426
}
427427
}
428428

429-
impl<'a> ToVec for UnknownBlock<'a> {
429+
impl ToVec for UnknownBlock<'_> {
430430
fn fix(&mut self) {
431431
// do not touch type, it is unknown
432432
// fix length
@@ -450,7 +450,7 @@ impl<'a> ToVec for UnknownBlock<'a> {
450450
}
451451
}
452452

453-
impl<'a> ToVec for Block<'a> {
453+
impl ToVec for Block<'_> {
454454
fn fix(&mut self) {
455455
match self {
456456
Block::SectionHeader(b) => b.fix(),

src/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub enum MutableData<'a> {
1313
Borrowed(&'a mut [u8]),
1414
}
1515

16-
impl<'a> Data<'a> {
16+
impl Data<'_> {
1717
#[inline]
1818
pub fn as_slice(&self) -> &[u8] {
1919
match self {
@@ -77,21 +77,21 @@ impl<'a> MutableData<'a> {
7777

7878
/* AsRef */
7979

80-
impl<'a> AsRef<[u8]> for Data<'a> {
80+
impl AsRef<[u8]> for Data<'_> {
8181
#[inline]
8282
fn as_ref(&self) -> &[u8] {
8383
self.as_slice()
8484
}
8585
}
8686

87-
impl<'a> AsRef<[u8]> for MutableData<'a> {
87+
impl AsRef<[u8]> for MutableData<'_> {
8888
#[inline]
8989
fn as_ref(&self) -> &[u8] {
9090
self.as_slice()
9191
}
9292
}
9393

94-
impl<'a> AsMut<[u8]> for MutableData<'a> {
94+
impl AsMut<[u8]> for MutableData<'_> {
9595
#[inline]
9696
fn as_mut(&mut self) -> &mut [u8] {
9797
self.as_mut_slice()

0 commit comments

Comments
 (0)