pub struct PimdirBlobs { /* private fields */ }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
impl PimdirBlobs
Sourcepub fn open(dir: impl AsRef<Path>, hash: PimdirHashAlgo) -> Self
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.
Sourcepub fn hash_algo(&self) -> PimdirHashAlgo
pub fn hash_algo(&self) -> PimdirHashAlgo
The hash bodies here are named by.
Sourcepub fn hash(&self, bytes: &[u8]) -> ReplicaHash
pub fn hash(&self, bytes: &[u8]) -> ReplicaHash
The content hash of a whole body, under this store’s algorithm.
Sourcepub fn hasher(&self) -> PimdirHasher
pub fn hasher(&self) -> PimdirHasher
An incremental hasher, for a body streamed through
writer rather than held whole in memory.
Sourcepub fn path(&self, hash: &ReplicaHash) -> PathBuf
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.
Sourcepub fn get(&self, hash: &ReplicaHash) -> Result<Option<Vec<u8>>>
pub fn get(&self, hash: &ReplicaHash) -> Result<Option<Vec<u8>>>
Reads the body stored under hash from the sharded layout, or None
when absent.
Sourcepub fn reader(&self, hash: &ReplicaHash) -> Result<Option<File>>
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.
Sourcepub fn writer(&self) -> Result<PimdirBlobWriter>
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.
Sourcepub fn files(&self) -> Result<Vec<PimdirBlobFile>>
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
impl Clone for PimdirBlobs
Source§fn clone(&self) -> PimdirBlobs
fn clone(&self) -> PimdirBlobs
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more