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_formatsfield (new) persists the fullFormatConfigdirectly. - 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: u32Base repository format version. Tools must refuse to operate on a repository whose version exceeds what they understand.
algorithm: AlgorithmThe fs-verity algorithm configuration for this repository.
features: FeatureFlagsFeature flags.
erofs_formats: FormatConfigEROFS 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
impl RepoMetadata
Sourcepub fn erofs_version(&self) -> FormatVersion
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:
"v1_erofs"present →FormatVersion::V1- absent →
FormatVersion::V2
Sourcepub fn format_config(&self) -> FormatConfig
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
impl RepoMetadata
Sourcepub fn for_hash<ObjectID: FsVerityHashValue>() -> Self
pub fn for_hash<ObjectID: FsVerityHashValue>() -> Self
Build metadata for a repository using the given hash type, with the default EROFS version.
Sourcepub fn new(algorithm: Algorithm) -> Self
pub fn new(algorithm: Algorithm) -> Self
Build metadata from an explicit Algorithm, with the default EROFS format version.
Sourcepub fn new_with_formats(algorithm: Algorithm, formats: &FormatConfig) -> Self
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_formatsfield: stores the fullFormatConfigdirectly."v1_erofs"ro_compat flag: present when the primary version is V1, so that older tools that don’t knowerofs_formatsopen the repository read-only rather than writing images in the wrong format.
Sourcepub fn check_compatible<ObjectID: FsVerityHashValue>(
&self,
) -> Result<FeatureCheck, RepositoryOpenError>
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.
Trait Implementations§
Source§impl Clone for RepoMetadata
impl Clone for RepoMetadata
Source§fn clone(&self) -> RepoMetadata
fn clone(&self) -> RepoMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RepoMetadata
impl Debug for RepoMetadata
Source§impl<'de> Deserialize<'de> for RepoMetadata
impl<'de> Deserialize<'de> for RepoMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RepoMetadata
Source§impl PartialEq for RepoMetadata
impl PartialEq for RepoMetadata
Source§fn eq(&self, other: &RepoMetadata) -> bool
fn eq(&self, other: &RepoMetadata) -> bool
self and other values to be equal, and is used by ==.