Skip to main content

Metadata

Struct Metadata 

Source
pub struct Metadata { /* private fields */ }
Expand description

Metadata information about an entry.

§Examples

use libpna::{Duration, Metadata};

let since_unix_epoch = Duration::seconds(1000);
let metadata = Metadata::new()
    .with_accessed(Some(since_unix_epoch))
    .with_created(Some(since_unix_epoch))
    .with_modified(Some(since_unix_epoch));

Implementations§

Source§

impl Metadata

Source

pub const fn new() -> Metadata

Creates a new Metadata.

Source

pub const fn with_created(self, created: Option<Duration>) -> Metadata

Sets the created time as the duration since the Unix epoch.

§Examples
use libpna::{Duration, Metadata};

let since_unix_epoch = Duration::seconds(1000);
let metadata = Metadata::new().with_created(Some(since_unix_epoch));
Source

pub const fn with_modified(self, modified: Option<Duration>) -> Metadata

Sets the modified time as the duration since the Unix epoch.

§Examples
use libpna::{Duration, Metadata};

let since_unix_epoch = Duration::seconds(1000);
let metadata = Metadata::new().with_modified(Some(since_unix_epoch));
Source

pub const fn with_accessed(self, accessed: Option<Duration>) -> Metadata

Sets the accessed time as the duration since the Unix epoch.

§Examples
use libpna::{Duration, Metadata};

let since_unix_epoch = Duration::seconds(1000);
let metadata = Metadata::new().with_accessed(Some(since_unix_epoch));
Source

pub fn with_permission(self, permission: Option<Permission>) -> Metadata

👎Deprecated since 0.34.0:

the fPRM chunk is superseded by the owner facet chunks; use Metadata::with_owner_uid/with_owner_gid/with_owner_user_name/with_owner_group_name/with_owner_user_sid/with_owner_group_sid/with_permission_mode

Sets the permission of the entry.

Source

pub fn with_owner_uid(self, value: Option<OwnerUid>) -> Metadata

Sets the owner user id facet (fUId).

Source

pub fn with_owner_gid(self, value: Option<OwnerGid>) -> Metadata

Sets the owner group id facet (fGId).

Source

pub fn with_owner_user_name(self, value: Option<OwnerUserName>) -> Metadata

Sets the owner user name facet (fONm).

Source

pub fn with_owner_group_name(self, value: Option<OwnerGroupName>) -> Metadata

Sets the owner group name facet (fGNm).

Source

pub fn with_owner_user_sid(self, value: Option<OwnerUserSid>) -> Metadata

Sets the owner user SID facet (fOSi).

Source

pub fn with_owner_group_sid(self, value: Option<OwnerGroupSid>) -> Metadata

Sets the owner group SID facet (fGSi).

Source

pub fn with_permission_mode(self, value: Option<PermissionMode>) -> Metadata

Sets the POSIX permission mode facet (fMOd).

Sets the link target type of the entry. Only meaningful for symbolic link and hard link entries.

Source

pub const fn raw_file_size(&self) -> Option<u128>

Returns the raw file size of this entry’s data in bytes.

Source

pub const fn compressed_size(&self) -> usize

Returns the compressed size of this entry’s data in bytes.

Source

pub const fn created(&self) -> Option<Duration>

Returns the created time since the Unix epoch for the entry.

Source

pub const fn modified(&self) -> Option<Duration>

Returns the modified time since the Unix epoch for the entry.

Source

pub const fn accessed(&self) -> Option<Duration>

Returns the accessed time since the Unix epoch for the entry.

Source

pub const fn permission(&self) -> Option<&Permission>

👎Deprecated since 0.34.0:

the fPRM chunk is superseded by the owner facet chunks; use Metadata::owner_uid/owner_gid/owner_user_name/owner_group_name/owner_user_sid/owner_group_sid/permission_mode

Returns the owner, group, and permission bits for the entry.

Source

pub const fn owner_uid(&self) -> Option<OwnerUid>

Returns the owner user id facet (fUId), if recorded.

Source

pub const fn owner_gid(&self) -> Option<OwnerGid>

Returns the owner group id facet (fGId), if recorded.

Source

pub fn owner_user_name(&self) -> Option<&OwnerUserName>

Returns the owner user name facet (fONm), if recorded.

Source

pub fn owner_group_name(&self) -> Option<&OwnerGroupName>

Returns the owner group name facet (fGNm), if recorded.

Source

pub fn owner_user_sid(&self) -> Option<&OwnerUserSid>

Returns the owner user SID facet (fOSi), if recorded.

Source

pub fn owner_group_sid(&self) -> Option<&OwnerGroupSid>

Returns the owner group SID facet (fGSi), if recorded.

Source

pub const fn permission_mode(&self) -> Option<PermissionMode>

Returns the POSIX permission mode facet (fMOd), if recorded.

Returns the link target type for this entry, if present.

  • None: fLTP chunk was absent.
  • Some(Unknown): fLTP chunk present but target type undetermined.
  • Some(File) / Some(Directory): known target type.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Metadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Metadata

Source§

fn default() -> Metadata

Returns the “default value” for a type. Read more
Source§

impl Hash for Metadata

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl MetadataFsExt for Metadata

Source§

fn from_metadata(metadata: &Metadata) -> Result<Self>
where Self: Sized,

Creates a new Metadata from the given fs::Metadata.

§Examples
use pna::{Metadata, prelude::*};
use std::fs;

Metadata::from_metadata(&fs::metadata("path/to/file")?)?;
Ok(())
§Errors

Currently never returns an error.

Source§

impl MetadataPathExt for Metadata

Source§

fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
where Self: Sized,

Creates a new Metadata from the given path.

§Examples
use pna::{Metadata, prelude::*};

Metadata::from_path("path/to/file");
§Errors

Returns an error if std::fs::metadata returns an error.

Creates a new Metadata from the given path without following symlinks.

§Examples
use pna::{Metadata, prelude::*};

Metadata::from_symlink_path("path/to/file");
§Errors

Returns an error if std::fs::symlink_metadata returns an error.

Source§

impl MetadataTimeExt for Metadata

Source§

fn created_time(&self) -> Option<SystemTime>

👎Deprecated since 0.34.0:

panics for archive timestamps outside the platform’s SystemTime range; use try_created_time or saturating_created_time

Returns the created time.

This is the same as Metadata::created + SystemTime::UNIX_EPOCH.

use pna::{Duration, Metadata, prelude::*};
use std::time::UNIX_EPOCH;

let metadata = Metadata::new().with_created(Some(Duration::seconds(1000)));

assert_eq!(
    metadata.created().map(|d| UNIX_EPOCH + d),
    metadata.created_time(),
);
Source§

fn modified_time(&self) -> Option<SystemTime>

👎Deprecated since 0.34.0:

panics for archive timestamps outside the platform’s SystemTime range; use try_modified_time or saturating_modified_time

Returns the modified time.

This is the same as Metadata::modified + SystemTime::UNIX_EPOCH.

use pna::{Duration, Metadata, prelude::*};
use std::time::UNIX_EPOCH;

let metadata = Metadata::new().with_modified(Some(Duration::seconds(1000)));

assert_eq!(
    metadata.modified().map(|d| UNIX_EPOCH + d),
    metadata.modified_time(),
);
Source§

fn accessed_time(&self) -> Option<SystemTime>

👎Deprecated since 0.34.0:

panics for archive timestamps outside the platform’s SystemTime range; use try_accessed_time or saturating_accessed_time

Returns the accessed time.

This is the same as Metadata::accessed + SystemTime::UNIX_EPOCH.

use pna::{Duration, Metadata, prelude::*};
use std::time::UNIX_EPOCH;

let metadata = Metadata::new().with_accessed(Some(Duration::seconds(1000)));

assert_eq!(
    metadata.accessed().map(|d| UNIX_EPOCH + d),
    metadata.accessed_time(),
);
Source§

fn with_created_time(self, time: impl Into<Option<SystemTime>>) -> Self

Sets the created time.

§Examples
use pna::{Metadata, prelude::*};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

// Time after Unix epoch will be preserved
let after_epoch = UNIX_EPOCH + Duration::from_secs(1000);
let metadata = Metadata::new().with_created_time(Some(after_epoch));
assert_eq!(metadata.created_time(), Some(after_epoch));

let before_epoch = UNIX_EPOCH - Duration::from_secs(1);
let metadata = Metadata::new().with_created_time(Some(before_epoch));
assert_eq!(metadata.created_time(), Some(before_epoch));
Source§

fn with_modified_time(self, time: impl Into<Option<SystemTime>>) -> Self

Sets the modified time.

§Examples
use pna::{Metadata, prelude::*};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

// Time after Unix epoch will be preserved
let after_epoch = UNIX_EPOCH + Duration::from_secs(1000);
let metadata = Metadata::new().with_modified_time(Some(after_epoch));
assert_eq!(metadata.modified_time(), Some(after_epoch));

let before_epoch = UNIX_EPOCH - Duration::from_secs(1);
let metadata = Metadata::new().with_modified_time(Some(before_epoch));
assert_eq!(metadata.modified_time(), Some(before_epoch));
Source§

fn with_accessed_time(self, time: impl Into<Option<SystemTime>>) -> Self

Sets the accessed time.

§Examples
use pna::{Metadata, prelude::*};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

// Time after Unix epoch will be preserved
let after_epoch = UNIX_EPOCH + Duration::from_secs(1000);
let metadata = Metadata::new().with_accessed_time(Some(after_epoch));
assert_eq!(metadata.accessed_time(), Some(after_epoch));

let before_epoch = UNIX_EPOCH - Duration::from_secs(1);
let metadata = Metadata::new().with_accessed_time(Some(before_epoch));
assert_eq!(metadata.accessed_time(), Some(before_epoch));
Source§

fn try_created_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>

Returns the created time, or Err if the stored duration is outside the platform’s representable SystemTime range. Read more
Source§

fn try_modified_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>

Returns the modified time, or Err if the stored duration is outside the platform’s representable SystemTime range. Read more
Source§

fn try_accessed_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>

Returns the accessed time, or Err if the stored duration is outside the platform’s representable SystemTime range. Read more
Source§

fn saturating_created_time(&self) -> Option<SystemTime>

Returns the created time, clamping an out-of-range stored duration to the platform’s representable bound.
Source§

fn saturating_modified_time(&self) -> Option<SystemTime>

Returns the modified time, clamping an out-of-range stored duration to the platform’s representable bound.
Source§

fn saturating_accessed_time(&self) -> Option<SystemTime>

Returns the accessed time, clamping an out-of-range stored duration to the platform’s representable bound.
Source§

impl Ord for Metadata

Source§

fn cmp(&self, other: &Metadata) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Metadata

Source§

fn eq(&self, other: &Metadata) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Metadata

Source§

fn partial_cmp(&self, other: &Metadata) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Metadata

Source§

impl StructuralPartialEq for Metadata

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V