Skip to main content

PackWriter

Struct PackWriter 

Source
pub struct PackWriter {
    pub len: u64,
    pub entry_count: u64,
    pub offsets: HashMap<Hash, u64>,
    /* private fields */
}
Expand description

An open, append-only pack. Entries are appended one at a time; the trailer is written only at seal() time.

Fields§

§len: u64

Byte length of the file so far (header + entries written).

§entry_count: u64§offsets: HashMap<Hash, u64>

In-memory offset index for entries written this process — avoids a re-scan to serve a get() against data not yet sealed.

Implementations§

Source§

impl PackWriter

Source

pub fn open_active(path: &Path, partition_id: PartitionId) -> Result<Self>

Open (creating if absent) the active pack at path for partition_id, rebuilding in-memory state by scanning any bytes already there (resuming after a crash or a prior process exit).

Source

pub fn append( &mut self, hash: Hash, codec: Codec, uncompressed_len: u64, payload: &[u8], ) -> Result<u64>

Append one entry (dedup is the caller’s responsibility — this always writes). Returns the byte offset the entry starts at. Always emits the reserved values for flags/key_epoch — there is no parameter to supply anything else; that is the writer-side half of the fail-closed rule (module docs).

Source

pub fn append_raw(&mut self, meta: &EntryMeta, payload: &[u8]) -> Result<u64>

Append one entry with an arbitrary, caller-supplied EntryMeta — the byte-exact primitive a meta-preserving copy (GC’s repack) needs to relocate an entry without re-deriving flags/key_epoch from scratch. Not a route for ordinary callers to set reserved fields: PartitionStore::put only ever reaches this through PackWriter::append, which hard-codes the reserved values. packfile is implementation, explicitly outside the interface lock (see lib.rs); this is the escape hatch that exists for exactly one job.

Source

pub fn read_payload_at(&self, offset: u64) -> Result<(EntryMeta, Vec<u8>)>

Source

pub fn seal(self, packs_dir: &Path) -> Result<(Hash, PathBuf)>

Seal this pack: write the trailer, rename to its content-addressed final name (<pack_content_hash>.pack), and return the new id + path. The writer is consumed — callers open a fresh PackWriter for the next active pack.

Source

pub 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