Skip to main content

PimdirBlobs

Struct PimdirBlobs 

Source
pub struct PimdirBlobs { /* private fields */ }
Available on crate feature client only.
Expand description

A read-only handle to a pimdir store’s content-addressed blob directory, independent of the SQLite Connection.

A body can be read through it while the PimdirStore is mutably borrowed to service a sync, a remote reading a stored body back to re-upload it. Cheap to clone: it wraps only the objects/ path.

Implementations§

Source§

impl PimdirBlobs

Source

pub fn open(dir: impl AsRef<Path>, hash: PimdirHashAlgo) -> Self

Opens the blob handle for the store rooted at dir, naming bodies with hash.

The algorithm is the store’s, not a choice made here: it is what the files are named by. PimdirReader::blobs hands one out already bound to the store it came from.

Source

pub fn hash_algo(&self) -> PimdirHashAlgo

The hash bodies here are named by.

Source

pub fn hash(&self, bytes: &[u8]) -> ReplicaHash

The content hash of a whole body, under this store’s algorithm.

Source

pub fn hasher(&self) -> PimdirHasher

An incremental hasher, for a body streamed through writer rather than held whole in memory.

Source

pub fn path(&self, hash: &ReplicaHash) -> PathBuf

Where a body under hash lives: objects/<name[0:2]>/<name[2:4]>/<name> (spec §5).

Public because the format invites a consumer to stream a body straight to this path and index it with a byteless StoreObject afterwards (spec §14), and deriving the sharding itself would be a second implementation of a rule whose point is that one store’s writers agree on it.

Source

pub fn get(&self, hash: &ReplicaHash) -> Result<Option<Vec<u8>>>

Reads the body stored under hash from the sharded layout, or None when absent.

Source

pub fn reader(&self, hash: &ReplicaHash) -> Result<Option<File>>

Opens a stored object as a readable stream, or None when absent: the append side of bounded-memory transfer, so a body is uploaded without being read whole into memory. The file’s metadata gives the octet length IMAP APPEND needs up front.

Source

pub fn writer(&self) -> Result<PimdirBlobWriter>

Opens a streaming writer for a new object: bytes go to a temporary file and reach their content-addressed path only on commit, once the hash is known. The caller hashes the bytes as it writes them.

Source

pub fn files(&self) -> Result<Vec<PimdirBlobFile>>

Every body the blob tree holds, walking the two-level sharding.

The files, not the index: what a collector and a consistency check compare the object rows against, the difference either way being a defect. A half-written body is skipped, a temp file belonging to a writer that has not committed.

Trait Implementations§

Source§

impl Clone for PimdirBlobs

Source§

fn clone(&self) -> PimdirBlobs

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 PimdirBlobs

Source§

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

Formats the value using the given formatter. Read more

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> 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 = !

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.