Skip to main content

PgBlobStore

Struct PgBlobStore 

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

Content-addressed blobs: containers under a root directory, key material and bookkeeping in gwk_internal.

Implementations§

Source§

impl PgBlobStore

Source

pub async fn open(pool: PgPool, config: BlobConfig) -> Result<Self, BlobError>

Bind to an initialized database and prepare the root directory.

Creating the directories here rather than lazily means a root that is unwritable is a startup failure, not a failure of the first upload that happens to arrive in production.

Source

pub fn config(&self) -> &BlobConfig

Source

pub async fn expire_uploads(&self) -> Result<(), BlobError>

Drop uploads that outlived UPLOAD_EXPIRY_SECS, with their files.

Called from open, from begin, and from sweep rather than by a timer: an expiry only has to hold for a store somebody is using, and a background task would be a second thing to supervise for no more guarantee than this.

Source

pub async fn rewrap_all(&self, new_kek: &[u8; 32]) -> Result<usize, BlobError>

Rewrap every blob this KEK label covers under new_kek, touching no ciphertext.

The label does NOT change: it is inside each container’s authenticated header, so a rewrap that relabeled would invalidate the very AAD the new wrap is bound to. Rotation replaces the key behind the name.

Trait Implementations§

Source§

impl BlobStore for PgBlobStore

Source§

async fn begin( &self, media_type: String, byte_size: ByteCount, ) -> Result<BlobUploadId, BlobError>

Start an upload. The caller declares what it intends to write; the store mints the id and owns the temporary file.
Source§

async fn write_chunk( &self, upload: &BlobUploadId, sequence: u32, chunk: &[u8], ) -> Result<(), BlobError>

Append one plaintext chunk. sequence is contiguous from 0; a gap or a repeat is refused rather than reordered.
Source§

async fn commit( &self, upload: BlobUploadId, address: BlobAddress, ) -> Result<(BlobDescriptor, bool), BlobError>

Finish the upload, requiring the plaintext to hash to address. Read more
Source§

async fn abort(&self, upload: BlobUploadId) -> Result<(), BlobError>

Discard an upload and its temporary file. Uncommitted uploads also expire on their own after an hour.
Source§

async fn read( &self, address: &BlobAddress, offset: ByteCount, length: ByteCount, ) -> Result<Vec<u8>, BlobError>

Read a bounded range of plaintext.
Source§

async fn stat( &self, address: &BlobAddress, ) -> Result<Option<BlobDescriptor>, BlobError>

Describe a committed blob. Ok(None) means it never existed; BlobError::Tombstoned means it did and was shredded — a distinction a retention audit needs.
Source§

async fn pin( &self, address: &BlobAddress, evidence: &EvidenceId, ) -> Result<(), BlobError>

Pin as evidence, blocking sweep until every pin is released.
Source§

async fn unpin( &self, address: &BlobAddress, evidence: &EvidenceId, ) -> Result<(), BlobError>

Source§

async fn sweep(&self) -> Result<Vec<BlobAddress>, BlobError>

Remove unreferenced, unpinned blobs; returns what it removed.
Source§

async fn shred(&self, address: &BlobAddress) -> Result<(), BlobError>

Crypto-shred: commit the tombstone and drop the wrapped DEK FIRST, then remove ciphertext. Ordered that way so a crash mid-shred leaves an unreadable blob, never a readable one.

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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