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
impl PgBlobStore
Sourcepub async fn open(pool: PgPool, config: BlobConfig) -> Result<Self, BlobError>
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.
pub fn config(&self) -> &BlobConfig
Sourcepub async fn expire_uploads(&self) -> Result<(), BlobError>
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.
Sourcepub async fn rewrap_all(&self, new_kek: &[u8; 32]) -> Result<usize, BlobError>
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
impl BlobStore for PgBlobStore
Source§async fn begin(
&self,
media_type: String,
byte_size: ByteCount,
) -> Result<BlobUploadId, BlobError>
async fn begin( &self, media_type: String, byte_size: ByteCount, ) -> Result<BlobUploadId, BlobError>
Source§async fn write_chunk(
&self,
upload: &BlobUploadId,
sequence: u32,
chunk: &[u8],
) -> Result<(), BlobError>
async fn write_chunk( &self, upload: &BlobUploadId, sequence: u32, chunk: &[u8], ) -> Result<(), BlobError>
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>
async fn commit( &self, upload: BlobUploadId, address: BlobAddress, ) -> Result<(BlobDescriptor, bool), BlobError>
address. Read moreSource§async fn abort(&self, upload: BlobUploadId) -> Result<(), BlobError>
async fn abort(&self, upload: BlobUploadId) -> Result<(), BlobError>
Source§async fn read(
&self,
address: &BlobAddress,
offset: ByteCount,
length: ByteCount,
) -> Result<Vec<u8>, BlobError>
async fn read( &self, address: &BlobAddress, offset: ByteCount, length: ByteCount, ) -> Result<Vec<u8>, BlobError>
Source§async fn stat(
&self,
address: &BlobAddress,
) -> Result<Option<BlobDescriptor>, BlobError>
async fn stat( &self, address: &BlobAddress, ) -> Result<Option<BlobDescriptor>, BlobError>
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>
async fn pin( &self, address: &BlobAddress, evidence: &EvidenceId, ) -> Result<(), BlobError>
async fn unpin( &self, address: &BlobAddress, evidence: &EvidenceId, ) -> Result<(), BlobError>
Auto Trait Implementations§
impl !RefUnwindSafe for PgBlobStore
impl !UnwindSafe for PgBlobStore
impl Freeze for PgBlobStore
impl Send for PgBlobStore
impl Sync for PgBlobStore
impl Unpin for PgBlobStore
impl UnsafeUnpin for PgBlobStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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