Skip to main content

PreservedMeta

Struct PreservedMeta 

Source
pub struct PreservedMeta {
    pub mode: Option<u32>,
    pub uid: Option<u32>,
    pub gid: Option<u32>,
    pub os_type: Option<[u8; 4]>,
    pub os_creator: Option<[u8; 4]>,
    pub aux_type: Option<u16>,
    pub dos_attributes: Option<u16>,
    pub amiga_protection: Option<u32>,
    pub amiga_comment: Option<String>,
    pub amiga_dates: Option<(i32, i32, i32)>,
    pub mac_dates: Option<(u32, u32, u32)>,
    pub xattrs: Vec<Xattr>,
}
Expand description

Everything worth carrying from a file that is about to be replaced.

Replacing a file writes new contents; it is not a request to reset who may read it, when it was made, or what application owns it. But a replace is implemented as delete-then-create on every filesystem here, so unless these are captured first they are simply gone. Only xattrs used to be carried, which meant fixing one line of a config file silently reset its permissions, owner and timestamps.

Capture with preserved_meta before the delete, apply with PreservedMeta::apply_to_options and PreservedMeta::reapply_dates.

Deliberately not preserved: the resource fork. That is content rather than metadata, and pairing a new data fork with the previous resource fork produces a file that is neither of the two things it came from.

Fields§

§mode: Option<u32>§uid: Option<u32>§gid: Option<u32>§os_type: Option<[u8; 4]>

Classic-Mac OSType / creator, kept raw so a non-ASCII code survives.

§os_creator: Option<[u8; 4]>§aux_type: Option<u16>

ProDOS auxiliary type (a file’s load address, say).

§dos_attributes: Option<u16>

FAT attribute bits: read-only, hidden, system, archive.

§amiga_protection: Option<u32>§amiga_comment: Option<String>§amiga_dates: Option<(i32, i32, i32)>§mac_dates: Option<(u32, u32, u32)>

(created, modified, backup) in Mac epoch seconds.

§xattrs: Vec<Xattr>

Implementations§

Source§

impl PreservedMeta

Source

pub fn is_empty(&self) -> bool

Whether anything was actually captured, so callers can stay quiet when there is nothing to say.

Source

pub fn summary(&self) -> String

A short, ASCII-only summary for the log line — the GUI font has no glyph coverage beyond ASCII.

Source

pub fn apply_to_options(&self, opts: &mut CreateFileOptions)

Fill a [CreateFileOptions] with the preserved values, leaving anything the caller already set alone.

An explicit --type/--mode is an instruction and must win; preserved metadata is only the default for fields nobody spoke about.

Source

pub fn reapply_dates( &self, fs: &mut dyn EditableFilesystem, entry: &FileEntry, ) -> bool

Restore timestamps, which no filesystem here accepts at creation time.

Best-effort by design: a filesystem with no date setter answers Unsupported, and failing the whole write over a timestamp would be a worse outcome than the file keeping today’s date. Returns whether the dates were actually applied so the caller can report honestly.

Trait Implementations§

Source§

impl Clone for PreservedMeta

Source§

fn clone(&self) -> Self

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 PreservedMeta

Source§

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

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

impl Default for PreservedMeta

Source§

fn default() -> Self

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

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.