Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make const #309

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/archive/entry/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
30 changes: 15 additions & 15 deletions lib/src/archive/entry/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions lib/src/archive/entry/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Duration> {
pub const fn created(&self) -> Option<Duration> {
self.created
}
/// Modified time since unix epoch time of entry
#[inline]
pub fn modified(&self) -> Option<Duration> {
pub const fn modified(&self) -> Option<Duration> {
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()
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/archive/entry/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl ReadOption {
/// let builder = ReadOption::builder();
/// ```
#[inline]
pub fn builder() -> ReadOptionBuilder {
pub const fn builder() -> ReadOptionBuilder {
#[allow(deprecated)]
ReadOptionBuilder::new()
}
Expand Down Expand Up @@ -335,7 +335,7 @@ impl From<ReadOption> 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 }
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/archive/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<R: Read> Archive<R> {
///
/// [ANXT]: ChunkType::ANXT
#[inline]
pub fn next_archive(&self) -> bool {
pub const fn next_archive(&self) -> bool {
self.next_archive
}

Expand Down