Skip to main content

RepoMetadata

Struct RepoMetadata 

Source
pub struct RepoMetadata {
    pub version: u32,
    pub algorithm: Algorithm,
    pub features: FeatureFlags,
    pub erofs_formats: FormatConfig,
}
Expand description

Repository metadata stored in meta.json at the repository root.

This file records the repository’s format version, digest algorithm, feature flags, and EROFS format configuration so that tools can detect misconfigured invocations (e.g. opening a sha256 repo with --hash sha512) and so the algorithm and format don’t need to be specified on every command.

The versioning model is inspired by Linux filesystem superblocks (ext4, XFS, EROFS): a base version integer for fundamental layout changes, plus three tiers of feature flags for finer-grained evolution.

The EROFS format configuration is stored in two ways for compatibility:

  • The erofs_formats field (new) persists the full FormatConfig directly.
  • The "v1_erofs" ro_compat flag (legacy) is kept for old-tool compat.

When reading old repos without an erofs_formats field, the serde default gives FormatConfig::single(V2), which is then overridden to single(V1) if the "v1_erofs" flag is present.

Fields§

§version: u32

Base repository format version. Tools must refuse to operate on a repository whose version exceeds what they understand.

§algorithm: Algorithm

The fs-verity algorithm configuration for this repository.

§features: FeatureFlags

Feature flags.

§erofs_formats: FormatConfig

EROFS format configuration for images produced by this repository.

Persisted directly so that dual-format repositories (e.g. V1+V2) can round-trip through meta.json. For repositories created before this field existed, the field is absent from JSON and defaults to FormatConfig::single(FormatVersion::V2); the "v1_erofs" flag is then checked for seamless migration of old V1 repos.

Implementations§

Source§

impl RepoMetadata

Source

pub fn erofs_version(&self) -> FormatVersion

Derive the effective EROFS format version for this repository.

Uses erofs_formats.default when the field was explicitly set (i.e. is not the serde default of single(V2)). For old repos that predate the erofs_formats field, falls back to the "v1_erofs" ro_compat flag:

Source

pub fn format_config(&self) -> FormatConfig

Return the effective FormatConfig for this repository.

If erofs_formats was explicitly set in meta.json (i.e. it is not the serde default single(V2)), it is returned as-is. Otherwise the config is derived from the legacy "v1_erofs" ro_compat flag for backward compatibility with repos created before the erofs_formats field existed.

Source§

impl RepoMetadata

Source

pub fn for_hash<ObjectID: FsVerityHashValue>() -> Self

Build metadata for a repository using the given hash type, with the default EROFS version.

Source

pub fn new(algorithm: Algorithm) -> Self

Build metadata from an explicit Algorithm, with the default EROFS format version.

Source

pub fn new_with_formats(algorithm: Algorithm, formats: &FormatConfig) -> Self

Build metadata with the correct feature flags for the given FormatConfig.

The on-disk encoding uses a feature flag for compatibility:

  • erofs_formats field: stores the full FormatConfig directly.
  • "v1_erofs" ro_compat flag: present when the primary version is V1, so that older tools that don’t know erofs_formats open the repository read-only rather than writing images in the wrong format.
Source

pub fn check_compatible<ObjectID: FsVerityHashValue>( &self, ) -> Result<FeatureCheck, RepositoryOpenError>

Check whether this metadata is compatible with the given hash type.

Validates the base version, feature flags, and algorithm. Returns a FeatureCheck indicating read-write or read-only access.

Source

pub fn to_json(&self) -> Result<Vec<u8>>

Serialize to pretty-printed JSON with a trailing newline.

Source

pub fn from_json(data: &[u8]) -> Result<Self>

Deserialize from JSON bytes.

Trait Implementations§

Source§

impl Clone for RepoMetadata

Source§

fn clone(&self) -> RepoMetadata

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 RepoMetadata

Source§

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

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

impl<'de> Deserialize<'de> for RepoMetadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for RepoMetadata

Source§

impl PartialEq for RepoMetadata

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for RepoMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RepoMetadata

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.