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
pub fn with_permission(self, permission: Option<Permission>) -> Metadata
Sets the permission of the entry.
Sourcepub const fn raw_file_size(&self) -> Option<u128>
pub const fn raw_file_size(&self) -> Option<u128>
Raw file size of entry data in bytes
Sourcepub const fn compressed_size(&self) -> usize
pub const fn compressed_size(&self) -> usize
Compressed size of entry 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>
pub const fn permission(&self) -> Option<&Permission>
An owner, group, and permissions for an entry
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>
fn created_time(&self) -> Option<SystemTime>
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>
fn modified_time(&self) -> Option<SystemTime>
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>
fn accessed_time(&self) -> Option<SystemTime>
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§impl Ord for Metadata
impl Ord for Metadata
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 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