Skip to main content

S3BackendBuilder

Struct S3BackendBuilder 

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

Settings of an S3Backend, set through the methods below and applied by build.

Implementations§

Source§

impl S3BackendBuilder

Source

pub fn credentials( self, access_key: impl Into<String>, secret_key: impl Into<String>, ) -> Self

Sets the access key and secret key that sign requests. Required.

Source

pub fn session_token(self, token: impl Into<String>) -> Self

Sets the session token of temporary credentials.

Source

pub fn prefix(self, prefix: impl AsRef<str>) -> Self

Serves the keys below prefix as the share root. Leading and trailing / are dropped. The default is the whole bucket.

Source

pub fn path_style(self, path_style: bool) -> Self

Puts the bucket name in the URL path (true) or in the host name (false). By default an amazonaws.com endpoint with a bucket name that is a DNS label uses the host name, and every other endpoint the path.

Source

pub fn cache_dir(self, dir: impl Into<PathBuf>) -> Self

Keeps what clients change in dir. The backend makes dir if it is missing and locks it until every clone of the backend is dropped, the handles opened through it are closed and the requests in flight have ended. The directory must belong to this endpoint, bucket, prefix and case setting, and be on storage that survives a restart: what it holds is not in the bucket. On Windows it must be on a local NTFS or ReFS volume; build refuses one on an SMB share or a mapped network drive.

Required unless the backend is read_only, and refused with it.

Source

pub fn read_only(self) -> Self

Refuses every change to the share. The backend then needs no cache_dir, and one is refused.

Source

pub fn case_insensitive(self, case_insensitive: bool) -> Self

Sets whether names match without regard to case. On by default: a name that no key spells exactly opens the first key that differs only in case, and a job that stores a file waits while another job stores, or a request deletes, a key that differs from its own only in case. Off, every name is exactly a key, so the store has to keep case: on a store that holds Doc and doc as one object, a change to one overwrites or deletes the other. A cache directory is used with one setting only.

Source

pub fn request_timeout(self, timeout: Duration) -> Self

Sets how long the store requests for one call from a client may take in all, retries included. The default is 30 seconds.

Source

pub fn metadata_ttl(self, ttl: Duration) -> Self

Sets how long the backend trusts what it read from the store, such as a listing or the size of a file. The default is 30 seconds.

Source

pub fn listing_metadata_max(self, max: usize) -> Self

Sets how many entries of one listing get the times stored with them, read with one request each. Entries whose metadata the backend already holds do not count: they report their stored times whatever this is. Past the cap, or when its request fails or runs out of time, a file reports the time the store modified it and a directory the time the backend was built. The default is 1000; 0 reads none.

Source

pub fn upload_delay(self, delay: Duration) -> Self

Sets how long a file rests after its last change before the backend stores it in the bucket. A file that is open and left alone is stored too. Opening a file without overwriting it, or closing it, is not a change. A change to a file that is being stored stops the upload, and the file rests this long again. Renames, and times and attributes set on a file or directory, are stored after the same rest. The old key of a renamed file is deleted once the new key holds its content. The objects of deleted files are deleted in batches once nothing has been deleted for this long, at most a minute after the first of them was due. The default is 5 seconds.

Source

pub fn part_size(self, bytes: u64) -> Self

Sets the size of the parts of a multipart upload, from 5 MiB to 5 GiB. A file of up to this many bytes is stored with one request; a larger one is stored in parts of this size. A file that would take more than 10,000 parts is stored in larger parts. The default is 16 MiB.

Source

pub fn upload_concurrency(self, concurrency: usize) -> Self

Sets how many uploads run at once, and how many parts of a multipart upload are in flight at once for each. A listing keeps four times this many HEAD requests in flight, at most 64. The default is 4.

Source

pub fn read_chunk(self, bytes: u32) -> Self

Sets the size of the chunks that reads of objects with an ETag request, from 64 KiB to 32 MiB. Chunks are counted from the start of the object, and a read requests those that hold its bytes. A read of an object without an ETag requests the bytes it asks for. The backend keeps chunks for later reads while a handle that reads their version of the object is open: up to 4 chunks of each version, and 128 MiB of chunks over all versions. The default is 8 MiB.

Source

pub fn max_dir_rename_objects(self, max: usize) -> Self

Sets the most objects a renamed directory may hold: the objects below it in the bucket and the entries the backend holds for it. A rename of a directory with more fails with AccessDenied and changes nothing. The objects move after the rename answers. The cap bounds the memory and the cache directory space a move takes. The default is 10,000.

Source

pub async fn build(self) -> Result<S3Backend, S3Error>

Checks the settings and the bucket, and returns the backend.

§Errors

Fails for settings that cannot be used and for a platform without root certificates.

Fails for a cache directory that cannot be used, is locked by another backend, belongs to another endpoint, bucket, prefix or case setting, or has files and no identity.

Fails when one request for the keys below the prefix fails: the store answers with an error, as for a bucket that does not exist or credentials it refuses, or does not answer, as for an unreachable endpoint or a timeout. The request runs before the cache directory is read back.

Files an earlier backend recorded come back into the share with their times and attributes. The backend stores them, and the directory markers, renames and deletes an earlier one left, without waiting for the upload delay, including those whose upload failed. A file comes back as last recorded: one made and never recorded is gone, and an object changed and never recorded reads as the bucket has it. A file in the cache directory that cannot be read back moves to its conflicts directory, with an error in the log.

Trait Implementations§

Source§

impl Debug for S3BackendBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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

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

fn try_from(value: U) -> Result<T, !>

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