Skip to main content

Metadata

Struct Metadata 

Source
pub struct Metadata {
    pub shamir_threshold: Option<u32>,
    pub lastmodified: String,
    pub mac: String,
    pub unencrypted_suffix: Option<String>,
    pub encrypted_suffix: Option<String>,
    pub unencrypted_regex: Option<String>,
    pub encrypted_regex: Option<String>,
    pub unencrypted_comment_regex: Option<String>,
    pub encrypted_comment_regex: Option<String>,
    pub mac_only_encrypted: bool,
    pub version: String,
    /* private fields */
}
Expand description

The sops: metadata block.

Field order below is byte order in the file — see the module docs. Key arrays are private and derived; see Metadata::from_wrapped.

Fields§

§shamir_threshold: Option<u32>

Shamir threshold, when key groups are in use.

§lastmodified: String

lastmodified, kept verbatim as it appeared in the file.

Not a parsed timestamp, and deliberately so: this string is the AAD of the mac field, so any normalisation we applied on the way through — Z becoming +00:00, a dropped fractional second — would silently make a valid file unreadable.

§mac: String

The mac field, still in its ENC[…] form.

§unencrypted_suffix: Option<String>§encrypted_suffix: Option<String>§unencrypted_regex: Option<String>§encrypted_regex: Option<String>§unencrypted_comment_regex: Option<String>§encrypted_comment_regex: Option<String>§mac_only_encrypted: bool§version: String

Implementations§

Source§

impl Metadata

Source

pub fn from_wrapped( keys: Vec<WrappedKey>, lastmodified: impl Into<String>, mac: impl Into<String>, ) -> Self

Build metadata from the keys that actually exist.

This is the only constructor. There is no Metadata { age: … } literal available to a caller and no setter for a recipient list, which is what makes “declared recipients disagree with the ciphertext” unrepresentable in an emitted file.

Source

pub fn keys(&self) -> &[WrappedKey]

Every wrapped key, in file order.

Source

pub fn keys_for(&self, provider: KeyProvider) -> Vec<&WrappedKey>

The wrapped keys for one provider, in file order — the projection the sops.<provider> array is emitted from.

Source

pub fn age_keys(&self) -> Vec<AgeKey>

The sops.age array, derived.

Source

pub fn providers(&self) -> Vec<KeyProvider>

Every provider present in this file, sorted for a stable report.

Source

pub fn unimplemented_providers(&self) -> Vec<KeyProvider>

The providers this file needs that this build cannot unwrap.

Empty means every key in the file is one we could open given the right identity. Non-empty is a refusal to name, not a reason to guess.

Source

pub fn rewrap(&mut self, keys: Vec<WrappedKey>) -> Result<(), WireError>

Replace the key set — a rekey or updatekeys.

Takes the whole set rather than offering add/remove, so the arrays stay a projection of one atomically-replaced truth. Refuses an empty set: a file with no wrapped keys can never be decrypted by anyone, and producing one is how a rekey bug becomes permanent data loss.

Source

pub fn selector(&self) -> Result<EncryptionSelector, WireError>

Build the compiled selector for this file’s policy.

Falls back to sops’s default (_unencrypted) when nothing is configured, matching upstream’s defaulting of UnencryptedSuffix.

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

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

impl Eq for Metadata

Source§

impl PartialEq for Metadata

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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> 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.