pub struct PartitionStore { /* private fields */ }Expand description
The reference ImmutableStore implementation: a single partition’s
packfiles on the local filesystem.
Implementations§
Source§impl PartitionStore
impl PartitionStore
Sourcepub fn create(
store_root: &Path,
partition_id: PartitionId,
spec: PartitionSpec,
) -> Result<Self>
pub fn create( store_root: &Path, partition_id: PartitionId, spec: PartitionSpec, ) -> Result<Self>
Provision a new partition (spec §3.7). Fails with
StorageError::PartitionAlreadyProvisioned if partition.json
already exists. The only place a partition directory is ever
created — open creates none.
Verifies PartitionId::derive("{subject.kind}:{subject.id}") == partition_id: a partition cannot be provisioned under a subject it
was not derived from. Writes the portable record
(partition.json, inside the partition directory, replicated) and
the local subject binding (partitions.local.json, at the store
root, never replicated) as two separate writes — see
crate::partition for why they are split.
There is no default retention class: spec.retention_class is a
required field, and this method never substitutes one.
Sourcepub fn open(store_root: &Path, partition_id: PartitionId) -> Result<Self>
pub fn open(store_root: &Path, partition_id: PartitionId) -> Result<Self>
Open an already-provisioned partition (spec §3.7). Fails with
StorageError::PartitionNotProvisioned if partition.json is
absent — there is no default retention class or fallback
behaviour, because defaulting here would be exactly the “decide
retention at ingest, not retrofit it” rule the record exists to
enforce. Creates no directories. Rebuilds/self-heals any missing
.idx files from their .pack counterparts — the index is
derived, never trusted blindly.
Does not require partitions.local.json to have an entry for
this partition — a replica has no local binding and is still
readable.
pub fn partition_root(&self) -> &Path
Sourcepub fn record(&self) -> &PartitionRecord
pub fn record(&self) -> &PartitionRecord
The portable partition record this store was opened with.
Deliberately carries no crate::partition::Subject — see
crate::partition’s module docs for why that omission is the
guarantee, not an oversight.
Sourcepub fn retention_class(&self) -> RetentionClass
pub fn retention_class(&self) -> RetentionClass
This partition’s retention class. Immutable for the partition’s
lifetime — there is no set_retention_class; no transition is
legal in either direction. Minting a new partition and copying into
it is the only way to change one.
Sourcepub fn encryption_mode(&self) -> EncryptionMode
pub fn encryption_mode(&self) -> EncryptionMode
This partition’s encryption mode. Immutable for the partition’s
lifetime — there is no set_encryption_mode; no transition is legal
in either direction. Minting a new partition and copying into it is
the only way to change one. This crate implements no encryption
today; plaintext is the only value any current caller can produce.
pub fn packs_dir(&self) -> PathBuf
pub fn manifests_dir(&self) -> PathBuf
Sourcepub fn write_manifest(&self, name: &str, manifest_json: &str) -> Result<PathBuf>
pub fn write_manifest(&self, name: &str, manifest_json: &str) -> Result<PathBuf>
Persist manifest_json under this partition’s manifests/ tree so
gc can discover it as a root to keep alive.
pub fn list_manifests(&self) -> Result<Vec<PathBuf>>
Sourcepub fn all_hashes(&self) -> Vec<Hash>
pub fn all_hashes(&self) -> Vec<Hash>
List every entry hash currently reachable in this partition — both sealed packs and the active pack.
pub fn sealed_pack_ids(&self) -> Vec<Hash>
Sourcepub fn active_entry_count(&self) -> u64
pub fn active_entry_count(&self) -> u64
Number of entries written into the still-open active pack (not yet
sealed into an immutable .pack). Exposed for ls summaries.
Sourcepub fn verify_all(&self) -> Result<u64>
pub fn verify_all(&self) -> Result<u64>
Verify every sealed pack’s trailer + every entry’s hash across the whole partition (sealed and active). Returns the number of entries checked.
Sourcepub fn seal_active(&mut self) -> Result<Option<Hash>>
pub fn seal_active(&mut self) -> Result<Option<Hash>>
Force-seal the current active pack even if it hasn’t hit the soft
cap. Used by gc (which needs a clean set of sealed packs to
rewrite) and is otherwise optional — the 128 MiB cap is the normal
trigger.
Source§impl PartitionStore
impl PartitionStore
Sourcepub fn get_raw(&self, hash: &Hash) -> Result<(EntryMeta, Vec<u8>)>
pub fn get_raw(&self, hash: &Hash) -> Result<(EntryMeta, Vec<u8>)>
Fetch (meta, payload) for hash without decoding, hash-
verifying, or validating reserved fields — the raw, byte-exact form
a meta-preserving copy (GC’s repack) needs so it can relocate an
entry without interpreting what it means. Contrast
ImmutableStore::get, which is the validated, decoded, verified
form real content reads go through. Additive: not part of the
frozen ImmutableStore trait.
Sourcepub fn put_raw(&mut self, meta: EntryMeta, payload: &[u8]) -> Result<Hash>
pub fn put_raw(&mut self, meta: EntryMeta, payload: &[u8]) -> Result<Hash>
Append payload verbatim under meta — the byte-exact primitive a
meta-preserving copy (GC’s repack) needs, bypassing the normal
encode path. meta.hash is trusted as-is: the caller is relocating
an already-hashed entry forward, not producing new content. Still
dedups against what this partition already holds. Additive: not
part of the frozen ImmutableStore trait, and carries no validation
— see packfile::EntryMeta::validate_reserved’s module docs for
why a byte-mover is deliberately meta-blind.
Trait Implementations§
Source§impl ImmutableStore for PartitionStore
impl ImmutableStore for PartitionStore
Auto Trait Implementations§
impl Forget for PartitionStore
impl Freeze for PartitionStore
impl Move for PartitionStore
impl RefUnwindSafe for PartitionStore
impl Send for PartitionStore
impl Sync for PartitionStore
impl Unpin for PartitionStore
impl UnsafeUnpin for PartitionStore
impl UnwindSafe for PartitionStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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