pub struct MemoryBlob { /* private fields */ }Expand description
An in-memory cratefield_core::Blob store for module tests.
MemoryBlob::new has no presigned URLs (signed_url reports
Unsupported, as a directory store does); MemoryBlob::with_presign signs
real SigV4 URLs that MemoryBlob::verify_presigned checks back.
Implementations§
Source§impl MemoryBlob
impl MemoryBlob
pub fn new() -> Self
Sourcepub fn with_presign(clock: Arc<dyn Clock>) -> Self
pub fn with_presign(clock: Arc<dyn Clock>) -> Self
Opts the store into presigning: signed_url and signed_put_url sign
real SigV4 URLs stamped from clock, checked back by
verify_presigned.
Sourcepub fn verify_presigned(
&self,
url: &str,
method: &str,
headers: &[(String, String)],
) -> Result<String, SigV4Error>
pub fn verify_presigned( &self, url: &str, method: &str, headers: &[(String, String)], ) -> Result<String, SigV4Error>
Verifies a URL this store minted, at its clock’s current time, and returns the key it names.
§Errors
As sigv4::verify_presigned,
or SigV4Error::Malformed without a clock or a URL path.
Trait Implementations§
Source§impl Blob for MemoryBlob
impl Blob for MemoryBlob
Source§fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
key: &'life1 str,
bytes: &'life2 [u8],
content_type: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
key: &'life1 str,
bytes: &'life2 [u8],
content_type: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Stores
bytes at key with content_type, replacing any existing
object. Implementations MUST reject a payload larger than
MAX_BLOB_BYTES with BlobError::TooLarge via
check_blob_size, before writing (issue #136).Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<BlobObject>, BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<BlobObject>, BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetches the object at
key, or None if there is none.Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Removes the object at
key. Idempotent: removing a missing key is Ok.Source§fn signed_url<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<String, BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn signed_url<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<String, BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A presigned
GET for key, valid for ttl: a URL that serves the
object directly, skipping the Worker. Adapters without presigned URLs
(a directory store) return BlobError::Unsupported; callers then
serve the bytes through get. The URL’s query string is
a bearer credential: never log it.Source§fn signed_put_url<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
content_type: &'life2 str,
content_length: Option<u64>,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<PresignedPut, BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn signed_put_url<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
content_type: &'life2 str,
content_length: Option<u64>,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<PresignedPut, BlobError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§impl Clone for MemoryBlob
impl Clone for MemoryBlob
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryBlob
impl !UnwindSafe for MemoryBlob
impl Freeze for MemoryBlob
impl Send for MemoryBlob
impl Sync for MemoryBlob
impl Unpin for MemoryBlob
impl UnsafeUnpin for MemoryBlob
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
Mutably borrows from an owned value. Read more