diff --git a/lib/src/archive/entry/builder.rs b/lib/src/archive/entry/builder.rs index 2384e8ec..92b907fc 100644 --- a/lib/src/archive/entry/builder.rs +++ b/lib/src/archive/entry/builder.rs @@ -33,7 +33,7 @@ impl EntryBuilder { /// # Returns /// /// A new [EntryBuilder]. - pub fn new_dir(name: EntryName) -> Self { + pub const fn new_dir(name: EntryName) -> Self { Self { header: EntryHeader::for_dir(name), phsf: None, diff --git a/lib/src/archive/entry/header.rs b/lib/src/archive/entry/header.rs index 2ec88051..58438d7b 100644 --- a/lib/src/archive/entry/header.rs +++ b/lib/src/archive/entry/header.rs @@ -16,7 +16,7 @@ pub struct EntryHeader { } impl EntryHeader { - pub(crate) fn new_with_options( + pub(crate) const fn new_with_options( data_kind: DataKind, compression: Compression, encryption: Encryption, @@ -34,7 +34,7 @@ impl EntryHeader { } } - pub(crate) fn new(data_kind: DataKind, path: EntryName) -> Self { + pub(crate) const fn new(data_kind: DataKind, path: EntryName) -> Self { Self::new_with_options( data_kind, Compression::No, @@ -45,7 +45,7 @@ impl EntryHeader { } #[inline] - pub(crate) fn for_file( + pub(crate) const fn for_file( compression: Compression, encryption: Encryption, cipher_mode: CipherMode, @@ -55,17 +55,17 @@ impl EntryHeader { } #[inline] - pub(crate) fn for_dir(path: EntryName) -> Self { + pub(crate) const fn for_dir(path: EntryName) -> Self { Self::new(DataKind::Directory, path) } #[inline] - pub(crate) fn for_symbolic_link(path: EntryName) -> Self { + pub(crate) const fn for_symbolic_link(path: EntryName) -> Self { Self::new(DataKind::SymbolicLink, path) } #[inline] - pub(crate) fn for_hard_link(path: EntryName) -> Self { + pub(crate) const fn for_hard_link(path: EntryName) -> Self { Self::new(DataKind::HardLink, path) } @@ -75,22 +75,22 @@ impl EntryHeader { } #[inline] - pub fn data_kind(&self) -> DataKind { + pub const fn data_kind(&self) -> DataKind { self.data_kind } #[inline] - pub fn compression(&self) -> Compression { + pub const fn compression(&self) -> Compression { self.compression } #[inline] - pub fn encryption(&self) -> Encryption { + pub const fn encryption(&self) -> Encryption { self.encryption } #[inline] - pub fn cipher_mode(&self) -> CipherMode { + pub const fn cipher_mode(&self) -> CipherMode { self.cipher_mode } @@ -142,7 +142,7 @@ pub struct SolidHeader { } impl SolidHeader { - pub(crate) fn new( + pub(crate) const fn new( compression: Compression, encryption: Encryption, cipher_mode: CipherMode, @@ -157,22 +157,22 @@ impl SolidHeader { } #[inline] - pub fn compression(&self) -> Compression { + pub const fn compression(&self) -> Compression { self.compression } #[inline] - pub fn encryption(&self) -> Encryption { + pub const fn encryption(&self) -> Encryption { self.encryption } #[inline] - pub fn cipher_mode(&self) -> CipherMode { + pub const fn cipher_mode(&self) -> CipherMode { self.cipher_mode } #[inline] - pub fn to_bytes(&self) -> [u8; 5] { + pub const fn to_bytes(&self) -> [u8; 5] { [ self.major, self.minor, diff --git a/lib/src/archive/entry/meta.rs b/lib/src/archive/entry/meta.rs index c34d64ee..73cb29c7 100644 --- a/lib/src/archive/entry/meta.rs +++ b/lib/src/archive/entry/meta.rs @@ -13,22 +13,22 @@ pub struct Metadata { impl Metadata { /// Compressed size of entry data #[inline] - pub fn compressed_size(&self) -> usize { + pub const fn compressed_size(&self) -> usize { self.compressed_size } /// Created time since unix epoch time of entry #[inline] - pub fn created(&self) -> Option { + pub const fn created(&self) -> Option { self.created } /// Modified time since unix epoch time of entry #[inline] - pub fn modified(&self) -> Option { + pub const fn modified(&self) -> Option { self.modified } /// A owner, group, and permissions for a entry #[inline] - pub fn permission(&self) -> Option<&Permission> { + pub const fn permission(&self) -> Option<&Permission> { self.permission.as_ref() } } @@ -62,7 +62,7 @@ impl Permission { /// let perm = Permission::new(1000, "user".to_string(), 100, "group".to_string(), 0o755); /// ``` #[inline] - pub fn new(uid: u64, uname: String, gid: u64, gname: String, permission: u16) -> Self { + pub const fn new(uid: u64, uname: String, gid: u64, gname: String, permission: u16) -> Self { Self { uid, uname, @@ -82,7 +82,7 @@ impl Permission { /// assert_eq!(perm.uid(), 1000); /// ``` #[inline] - pub fn uid(&self) -> u64 { + pub const fn uid(&self) -> u64 { self.uid } @@ -112,7 +112,7 @@ impl Permission { /// assert_eq!(perm.gid(), 100); /// ``` #[inline] - pub fn gid(&self) -> u64 { + pub const fn gid(&self) -> u64 { self.gid } @@ -142,7 +142,7 @@ impl Permission { /// assert_eq!(perm.permissions(), 0o644); /// ``` #[inline] - pub fn permissions(&self) -> u16 { + pub const fn permissions(&self) -> u16 { self.permission } diff --git a/lib/src/archive/entry/options.rs b/lib/src/archive/entry/options.rs index 92ddb99b..2a2474d6 100644 --- a/lib/src/archive/entry/options.rs +++ b/lib/src/archive/entry/options.rs @@ -295,7 +295,7 @@ impl ReadOption { /// let builder = ReadOption::builder(); /// ``` #[inline] - pub fn builder() -> ReadOptionBuilder { + pub const fn builder() -> ReadOptionBuilder { #[allow(deprecated)] ReadOptionBuilder::new() } @@ -335,7 +335,7 @@ impl From for ReadOptionBuilder { impl ReadOptionBuilder { #[deprecated(since = "0.2.0", note = "Use ReadOption::builder instead.")] - pub fn new() -> Self { + pub const fn new() -> Self { Self { password: None } } diff --git a/lib/src/archive/read.rs b/lib/src/archive/read.rs index 9590c22d..6672102f 100644 --- a/lib/src/archive/read.rs +++ b/lib/src/archive/read.rs @@ -157,7 +157,7 @@ impl Archive { /// /// [ANXT]: ChunkType::ANXT #[inline] - pub fn next_archive(&self) -> bool { + pub const fn next_archive(&self) -> bool { self.next_archive }