pub struct S3BackendBuilder { /* private fields */ }Implementations§
Source§impl S3BackendBuilder
impl S3BackendBuilder
Sourcepub fn credentials(
self,
access_key: impl Into<String>,
secret_key: impl Into<String>,
) -> Self
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.
Sourcepub fn session_token(self, token: impl Into<String>) -> Self
pub fn session_token(self, token: impl Into<String>) -> Self
Sets the session token of temporary credentials.
Sourcepub fn prefix(self, prefix: impl AsRef<str>) -> Self
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.
Sourcepub fn path_style(self, path_style: bool) -> Self
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.
Sourcepub fn cache_dir(self, dir: impl Into<PathBuf>) -> Self
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.
Sourcepub fn read_only(self) -> Self
pub fn read_only(self) -> Self
Refuses every change to the share. The backend then needs no
cache_dir, and one is refused.
Sourcepub fn case_insensitive(self, case_insensitive: bool) -> Self
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.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn metadata_ttl(self, ttl: Duration) -> Self
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.
Sourcepub fn listing_metadata_max(self, max: usize) -> Self
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.
Sourcepub fn upload_delay(self, delay: Duration) -> Self
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.
Sourcepub fn part_size(self, bytes: u64) -> Self
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.
Sourcepub fn upload_concurrency(self, concurrency: usize) -> Self
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.
Sourcepub fn read_chunk(self, bytes: u32) -> Self
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.
Sourcepub fn max_dir_rename_objects(self, max: usize) -> Self
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.
Sourcepub async fn build(self) -> Result<S3Backend, S3Error>
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.