pub struct S3DataCache { /* private fields */ }Expand description
Content-addressed storage backed by Amazon S3.
Implementations§
Source§impl S3DataCache
impl S3DataCache
pub fn new(bucket: String, key_prefix: String, client: Client) -> Self
Sourcepub fn with_multipart_part_size(self, size: usize) -> Self
pub fn with_multipart_part_size(self, size: usize) -> Self
Set the multipart part size for S3 transfers.
Sourcepub fn with_s3_check_cache(self, cache: Option<Arc<S3CheckCache>>) -> Self
pub fn with_s3_check_cache(self, cache: Option<Arc<S3CheckCache>>) -> Self
Attach an S3 check cache used to skip HeadObject calls.
Sourcepub fn with_force_s3_check(self, force: bool) -> Self
pub fn with_force_s3_check(self, force: bool) -> Self
If true, always call HeadObject even when the check cache has an entry.
Sourcepub fn with_expected_bucket_owner(self, owner: Option<String>) -> Self
pub fn with_expected_bucket_owner(self, owner: Option<String>) -> Self
Set the expected bucket owner account ID for S3 requests.
Sourcepub fn expected_bucket_owner(&self) -> Option<&str>
pub fn expected_bucket_owner(&self) -> Option<&str>
Returns the expected bucket owner account ID, if configured.
Sourcepub fn cache_key(&self, hash: &str, algorithm: &str) -> String
pub fn cache_key(&self, hash: &str, algorithm: &str) -> String
Returns the cache key for a given hash: “{bucket}/{prefix}/{hash}.{algorithm}”
Sourcepub fn is_cache_validation_invalidated(&self) -> bool
pub fn is_cache_validation_invalidated(&self) -> bool
Returns true if the probabilistic S3-check-cache validation has detected
a stale entry and invalidated the local cache. Primarily useful for tests.
Sourcepub async fn new_with_auto_account_id(
bucket: String,
key_prefix: String,
s3_client: Client,
sts_client: Client,
) -> Result<Self>
pub async fn new_with_auto_account_id( bucket: String, key_prefix: String, s3_client: Client, sts_client: Client, ) -> Result<Self>
Create with auto-detected account ID from AWS credentials.
Sourcepub fn check_cache_exists(&self, hash: &str, algorithm: &str) -> bool
pub fn check_cache_exists(&self, hash: &str, algorithm: &str) -> bool
Check the S3 check cache for an entry (without HeadObject).
Sourcepub fn record_in_check_cache(&self, hash: &str, algorithm: &str)
pub fn record_in_check_cache(&self, hash: &str, algorithm: &str)
Record that an object exists in S3 (update the check cache).
Trait Implementations§
Source§impl AsyncDataCache for S3DataCache
impl AsyncDataCache for S3DataCache
fn object_key(&self, hash: &str, algorithm: &str) -> String
fn as_any(&self) -> &dyn Any
Source§fn multipart_part_size(&self) -> usize
fn multipart_part_size(&self) -> usize
Returns the part size for multipart transfers. Default: 32MB. Read more
Source§fn as_multipart(&self) -> Option<&dyn MultipartDataCache>
fn as_multipart(&self) -> Option<&dyn MultipartDataCache>
Returns
Some(self) as a MultipartDataCache if the backend supports
S3-style multipart upload. Default: None.Source§fn as_range_read(&self) -> Option<&dyn RangeReadDataCache>
fn as_range_read(&self) -> Option<&dyn RangeReadDataCache>
Source§fn copy_from<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
source: &'life1 dyn AsyncDataCache,
hash: &'life2 str,
algorithm: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<CopyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn copy_from<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
source: &'life1 dyn AsyncDataCache,
hash: &'life2 str,
algorithm: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<CopyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Attempt a server-side copy from another cache. Returns
NotSupported by default.fn object_exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_object<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_object<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn copy_object_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
dest: &'life3 Path,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn copy_object_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
dest: &'life3 Path,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Copy a cached object directly to a file. The default reads into memory then writes.
Filesystem implementations can override for zero-copy (e.g. sendfile).
Source§fn write_object_to_file_at_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
dest: &'life3 Path,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn write_object_to_file_at_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
dest: &'life3 Path,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Write a cached object into an already-open file at a given offset.
Default reads into memory then writes. Filesystem can override for efficiency.
Source§impl MultipartDataCache for S3DataCache
impl MultipartDataCache for S3DataCache
fn create_multipart_upload<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn upload_part<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
upload_id: &'life3 str,
part_number: i32,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn complete_multipart_upload<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
upload_id: &'life3 str,
parts: Vec<(i32, String)>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn abort_multipart_upload<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
upload_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§impl RangeReadDataCache for S3DataCache
impl RangeReadDataCache for S3DataCache
fn get_object_range<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
start: u64,
end: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn stream_range_to_file_at_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
range_start: u64,
range_end: u64,
dest: &'life3 Path,
file_offset: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn stream_range_to_file_at_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
hash: &'life1 str,
algorithm: &'life2 str,
range_start: u64,
range_end: u64,
dest: &'life3 Path,
file_offset: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Stream a byte-range of a cached object directly to a file at a given offset.
Default uses get_object_range + write. S3 overrides to stream without buffering.
Auto Trait Implementations§
impl !Freeze for S3DataCache
impl !RefUnwindSafe for S3DataCache
impl Send for S3DataCache
impl Sync for S3DataCache
impl Unpin for S3DataCache
impl UnsafeUnpin for S3DataCache
impl !UnwindSafe for S3DataCache
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
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>
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 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>
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 moreCreates a shared type from an unshared type.