Skip to main content

S3DataCache

Struct S3DataCache 

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

Content-addressed storage backed by Amazon S3.

Implementations§

Source§

impl S3DataCache

Source

pub fn new(bucket: String, key_prefix: String, client: Client) -> Self

Source

pub fn with_multipart_part_size(self, size: usize) -> Self

Set the multipart part size for S3 transfers.

Source

pub fn with_s3_check_cache(self, cache: Option<Arc<S3CheckCache>>) -> Self

Attach an S3 check cache used to skip HeadObject calls.

Source

pub fn with_force_s3_check(self, force: bool) -> Self

If true, always call HeadObject even when the check cache has an entry.

Source

pub fn with_expected_bucket_owner(self, owner: Option<String>) -> Self

Set the expected bucket owner account ID for S3 requests.

Source

pub fn client(&self) -> &Client

Returns a reference to the underlying AWS S3 client.

Source

pub fn expected_bucket_owner(&self) -> Option<&str>

Returns the expected bucket owner account ID, if configured.

Source

pub fn cache_key(&self, hash: &str, algorithm: &str) -> String

Returns the cache key for a given hash: “{bucket}/{prefix}/{hash}.{algorithm}”

Source

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.

Source

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.

Source

pub fn check_cache_exists(&self, hash: &str, algorithm: &str) -> bool

Check the S3 check cache for an entry (without HeadObject).

Source

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

Source§

fn object_key(&self, hash: &str, algorithm: &str) -> String

Source§

fn as_any(&self) -> &dyn Any

Source§

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>

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>

Returns Some(self) as a RangeReadDataCache if the backend supports byte-range reads. Default: None.
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,

Attempt a server-side copy from another cache. Returns NotSupported by default.
Source§

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,

Source§

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,

Source§

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,

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,

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

Source§

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,

Source§

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,

Source§

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,

Source§

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

Source§

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,

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§

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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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