diff --git a/src/archive.rs b/src/archive.rs index 51c3f2c..4ea26d4 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -58,11 +58,13 @@ impl<'a> ArchiveEntry<'a> { /// Filename of the entry with a maximum of 100 characters (including the /// terminating NULL-byte). + #[must_use] pub const fn filename(&self) -> TarFormatString<{ POSIX_1003_MAX_FILENAME_LEN }> { self.filename } /// Data of the file. + #[must_use] pub const fn data(&self) -> &'a [u8] { self.data } @@ -74,6 +76,7 @@ impl<'a> ArchiveEntry<'a> { } /// Filesize in bytes. + #[must_use] pub const fn size(&self) -> usize { self.size } @@ -174,6 +177,7 @@ impl<'a> TarArchiveRef<'a> { } /// Creates an [`ArchiveEntryIterator`]. + #[must_use] pub fn entries(&self) -> ArchiveEntryIterator { ArchiveEntryIterator::new(self.data) } @@ -187,6 +191,7 @@ pub struct ArchiveHeaderIterator<'a> { } impl<'a> ArchiveHeaderIterator<'a> { + #[must_use] pub fn new(archive: &'a [u8]) -> Self { assert!(!archive.is_empty()); assert_eq!(archive.len() % BLOCKSIZE, 0); diff --git a/src/header.rs b/src/header.rs index 9d2d5de..ad32b7f 100644 --- a/src/header.rs +++ b/src/header.rs @@ -146,6 +146,7 @@ pub enum TypeFlag { impl TypeFlag { /// Whether we have a regular file. + #[must_use] pub fn is_regular_file(self) -> bool { // Equivalent. See spec. self == Self::AREGTYPE || self == Self::REGTYPE @@ -257,6 +258,7 @@ impl PosixHeader { /// A Tar archive is terminated, if an end-of-archive entry, which consists /// of two 512 blocks of zero bytes, is found. + #[must_use] pub fn is_zero_block(&self) -> bool { let ptr = self as *const Self as *const u8; let self_bytes = unsafe { core::slice::from_raw_parts(ptr, BLOCKSIZE) }; diff --git a/src/lib.rs b/src/lib.rs index 54f6612..08acf3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,6 +95,7 @@ SOFTWARE. clippy::all, clippy::cargo, clippy::nursery, + clippy::must_use_candidate, // clippy::restriction, // clippy::pedantic )] diff --git a/src/tar_format_types.rs b/src/tar_format_types.rs index 7b0ccbf..bab872a 100644 --- a/src/tar_format_types.rs +++ b/src/tar_format_types.rs @@ -23,6 +23,7 @@ pub struct TarFormatString { /// This string will be null terminated if it doesn't fill the entire array. impl TarFormatString { /// Constructor. + #[must_use] pub const fn new(bytes: [u8; N]) -> Self { if N == 0 { panic!("Array cannot be zero length"); @@ -31,12 +32,14 @@ impl TarFormatString { } /// True if the is string empty (ignoring NULL bytes). + #[must_use] pub const fn is_empty(&self) -> bool { self.bytes[0] == 0 } /// Returns the length of the payload in bytes. This is either the full /// capacity `N` or the data until the first NULL byte. + #[must_use] pub fn size(&self) -> usize { memchr::memchr(0, &self.bytes).unwrap_or(N) } @@ -121,6 +124,7 @@ impl TarFormatNumber { } /// Returns the underlying [`TarFormatString`]. + #[must_use] pub const fn as_inner(&self) -> &TarFormatString { &self.0 } @@ -157,6 +161,7 @@ impl TarFormatDecimal { } /// Returns the underlying [`TarFormatString`]. + #[must_use] pub const fn as_inner(&self) -> &TarFormatString { self.0.as_inner() } @@ -171,6 +176,7 @@ impl TarFormatOctal { } /// Returns the underlying [`TarFormatString`]. + #[must_use] pub const fn as_inner(&self) -> &TarFormatString { self.0.as_inner() }