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
impl Metadata
Sourcepub const fn with_created(self, created: Option<Duration>) -> Metadata
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));Sourcepub const fn with_modified(self, modified: Option<Duration>) -> Metadata
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));Sourcepub const fn with_accessed(self, accessed: Option<Duration>) -> Metadata
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));Sourcepub 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
pub fn with_permission(self, permission: Option<Permission>) -> Metadata
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.
Sourcepub fn with_owner_uid(self, value: Option<OwnerUid>) -> Metadata
pub fn with_owner_uid(self, value: Option<OwnerUid>) -> Metadata
Sets the owner user id facet (fUId).
Sourcepub fn with_owner_gid(self, value: Option<OwnerGid>) -> Metadata
pub fn with_owner_gid(self, value: Option<OwnerGid>) -> Metadata
Sets the owner group id facet (fGId).
Sourcepub fn with_owner_user_name(self, value: Option<OwnerUserName>) -> Metadata
pub fn with_owner_user_name(self, value: Option<OwnerUserName>) -> Metadata
Sets the owner user name facet (fONm).
Sourcepub fn with_owner_group_name(self, value: Option<OwnerGroupName>) -> Metadata
pub fn with_owner_group_name(self, value: Option<OwnerGroupName>) -> Metadata
Sets the owner group name facet (fGNm).
Sourcepub fn with_owner_user_sid(self, value: Option<OwnerUserSid>) -> Metadata
pub fn with_owner_user_sid(self, value: Option<OwnerUserSid>) -> Metadata
Sets the owner user SID facet (fOSi).
Sourcepub fn with_owner_group_sid(self, value: Option<OwnerGroupSid>) -> Metadata
pub fn with_owner_group_sid(self, value: Option<OwnerGroupSid>) -> Metadata
Sets the owner group SID facet (fGSi).
Sourcepub fn with_permission_mode(self, value: Option<PermissionMode>) -> Metadata
pub fn with_permission_mode(self, value: Option<PermissionMode>) -> Metadata
Sets the POSIX permission mode facet (fMOd).
Sourcepub const fn with_link_target_type(
self,
link_target_type: Option<LinkTargetType>,
) -> Metadata
pub const fn with_link_target_type( self, link_target_type: Option<LinkTargetType>, ) -> Metadata
Sets the link target type of the entry. Only meaningful for symbolic link and hard link entries.
Sourcepub const fn raw_file_size(&self) -> Option<u128>
pub const fn raw_file_size(&self) -> Option<u128>
Returns the raw file size of this entry’s data in bytes.
Sourcepub const fn compressed_size(&self) -> usize
pub const fn compressed_size(&self) -> usize
Returns the compressed size of this entry’s data in bytes.
Sourcepub const fn created(&self) -> Option<Duration>
pub const fn created(&self) -> Option<Duration>
Returns the created time since the Unix epoch for the entry.
Sourcepub const fn modified(&self) -> Option<Duration>
pub const fn modified(&self) -> Option<Duration>
Returns the modified time since the Unix epoch for the entry.
Sourcepub const fn accessed(&self) -> Option<Duration>
pub const fn accessed(&self) -> Option<Duration>
Returns the accessed time since the Unix epoch for the entry.
Sourcepub 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
pub const fn permission(&self) -> Option<&Permission>
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.
Sourcepub const fn owner_uid(&self) -> Option<OwnerUid>
pub const fn owner_uid(&self) -> Option<OwnerUid>
Returns the owner user id facet (fUId), if recorded.
Sourcepub const fn owner_gid(&self) -> Option<OwnerGid>
pub const fn owner_gid(&self) -> Option<OwnerGid>
Returns the owner group id facet (fGId), if recorded.
Sourcepub fn owner_user_name(&self) -> Option<&OwnerUserName>
pub fn owner_user_name(&self) -> Option<&OwnerUserName>
Returns the owner user name facet (fONm), if recorded.
Sourcepub fn owner_group_name(&self) -> Option<&OwnerGroupName>
pub fn owner_group_name(&self) -> Option<&OwnerGroupName>
Returns the owner group name facet (fGNm), if recorded.
Sourcepub fn owner_user_sid(&self) -> Option<&OwnerUserSid>
pub fn owner_user_sid(&self) -> Option<&OwnerUserSid>
Returns the owner user SID facet (fOSi), if recorded.
Sourcepub fn owner_group_sid(&self) -> Option<&OwnerGroupSid>
pub fn owner_group_sid(&self) -> Option<&OwnerGroupSid>
Returns the owner group SID facet (fGSi), if recorded.
Sourcepub const fn permission_mode(&self) -> Option<PermissionMode>
pub const fn permission_mode(&self) -> Option<PermissionMode>
Returns the POSIX permission mode facet (fMOd), if recorded.
Sourcepub const fn link_target_type(&self) -> Option<LinkTargetType>
pub const fn link_target_type(&self) -> Option<LinkTargetType>
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 MetadataFsExt for Metadata
impl MetadataFsExt for Metadata
Source§fn from_metadata(metadata: &Metadata) -> Result<Self>where
Self: Sized,
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
impl MetadataPathExt for Metadata
Source§fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>where
Self: Sized,
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.
Source§fn from_symlink_path<P: AsRef<Path>>(path: P) -> Result<Self>where
Self: Sized,
fn from_symlink_path<P: AsRef<Path>>(path: P) -> Result<Self>where
Self: Sized,
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
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
fn created_time(&self) -> Option<SystemTime>
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
fn modified_time(&self) -> Option<SystemTime>
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
fn accessed_time(&self) -> Option<SystemTime>
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
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
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
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>
fn try_created_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>
Err if the stored duration is outside
the platform’s representable SystemTime range. Read moreSource§fn try_modified_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>
fn try_modified_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>
Err if the stored duration is outside
the platform’s representable SystemTime range. Read moreSource§fn try_accessed_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>
fn try_accessed_time(&self) -> Result<Option<SystemTime>, SystemTimeOutOfRange>
Err if the stored duration is outside
the platform’s representable SystemTime range. Read moreSource§fn saturating_created_time(&self) -> Option<SystemTime>
fn saturating_created_time(&self) -> Option<SystemTime>
Source§fn saturating_modified_time(&self) -> Option<SystemTime>
fn saturating_modified_time(&self) -> Option<SystemTime>
Source§fn saturating_accessed_time(&self) -> Option<SystemTime>
fn saturating_accessed_time(&self) -> Option<SystemTime>
Source§impl Ord for Metadata
impl Ord for Metadata
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Metadata
impl PartialOrd for Metadata
impl Eq for Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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