Skip to main content

PartitionStore

Struct PartitionStore 

Source
pub struct PartitionStore { /* private fields */ }
Expand description

The reference ImmutableStore implementation: a single partition’s packfiles on the local filesystem.

Implementations§

Source§

impl PartitionStore

Source

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.

Source

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.

Source

pub fn partition_root(&self) -> &Path

Source

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.

Source

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.

Source

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.

Source

pub fn packs_dir(&self) -> PathBuf

Source

pub fn manifests_dir(&self) -> PathBuf

Source

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.

Source

pub fn list_manifests(&self) -> Result<Vec<PathBuf>>

Source

pub fn all_hashes(&self) -> Vec<Hash>

List every entry hash currently reachable in this partition — both sealed packs and the active pack.

Source

pub fn sealed_pack_ids(&self) -> Vec<Hash>

Source

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.

Source

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.

Source

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

Source

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.

Source

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

Source§

fn get(&self, hash: &Hash) -> Result<Vec<u8>>

Fetch and verify content by hash.
Source§

fn has(&self, hash: &Hash) -> bool

Source§

fn put(&mut self, data: &[u8]) -> Result<Hash>

Store data, returning its content hash. A put for content already present in this partition is a no-op dedup hit, not a duplicate write.
Source§

fn partition_id(&self) -> PartitionId

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more