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

Sets the permission of the entry.

Source

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

Raw file size of entry data in bytes

Source

pub const fn compressed_size(&self) -> usize

Compressed size of entry 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>

An owner, group, and permissions for an entry

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 · 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>

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>

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>

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§

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 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · 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 · 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 · 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 · 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 · 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 · 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