pub struct S3 { /* private fields */ }
Expand description
Wrapper of Rusoto S3 client that adds some high level imperative and declarative operations on S3 buckets and objects.
Implementations
sourceimpl S3
impl S3
sourcepub fn new(region: Region) -> S3
pub fn new(region: Region) -> S3
Creates new Rusoto based high level S3 client with default settings.
sourcepub fn new_with_settings(region: Region, settings: Settings) -> S3
pub fn new_with_settings(region: Region, settings: Settings) -> S3
Creates new Rusoto based high level S3 client with given settings.
sourcepub fn part_size(&self) -> usize
pub fn part_size(&self) -> usize
Gets maximum size of the multipart upload part.
Useful to set up other I/O buffers accordingly.
sourcepub fn max_upload_size(&self) -> usize
pub fn max_upload_size(&self) -> usize
Returns maximum size of data in bytes that S3 object can be put with.
sourcepub fn on_upload_progress(
&mut self,
callback: impl FnMut(&TransferStatus) + 'static
) -> Option<Box<dyn FnMut(&TransferStatus)>>
pub fn on_upload_progress(
&mut self,
callback: impl FnMut(&TransferStatus) + 'static
) -> Option<Box<dyn FnMut(&TransferStatus)>>
Set callback on body upload progress.
sourcepub fn with_on_upload_progress<O>(
&mut self,
callback: impl FnMut(&TransferStatus) + 'static,
f: impl FnOnce(&mut Self) -> O
) -> O
pub fn with_on_upload_progress<O>(
&mut self,
callback: impl FnMut(&TransferStatus) + 'static,
f: impl FnOnce(&mut Self) -> O
) -> O
Calls f
with S3
client that has on_upload_progress
set to callback
and restores
callback to previous state on return.
sourcepub fn check_bucket_exists(
&self,
bucket: Bucket
) -> Result<Either<Present<Bucket>, Absent<Bucket>>, S3SyncError>
pub fn check_bucket_exists(
&self,
bucket: Bucket
) -> Result<Either<Present<Bucket>, Absent<Bucket>>, S3SyncError>
Checks if given bucket exists.
sourcepub fn check_object_exists<'s, 'b>(
&'s self,
object: Object<'b>,
implementation: CheckObjectImpl
) -> Result<Either<Present<Object<'b>>, Absent<Object<'b>>>, S3SyncError>
pub fn check_object_exists<'s, 'b>(
&'s self,
object: Object<'b>,
implementation: CheckObjectImpl
) -> Result<Either<Present<Object<'b>>, Absent<Object<'b>>>, S3SyncError>
Checks if given object exists.
implementaiton
- select implementation of ths function
sourcepub fn check_object_exists_head<'s, 'b>(
&'s self,
object: Object<'b>
) -> Result<Either<Present<Object<'b>>, Absent<Object<'b>>>, S3SyncError>
pub fn check_object_exists_head<'s, 'b>(
&'s self,
object: Object<'b>
) -> Result<Either<Present<Object<'b>>, Absent<Object<'b>>>, S3SyncError>
Checks if given object exists by issuing HeadObject request.
Requires GetObject
premission.
sourcepub fn check_object_exists_list<'s, 'b>(
&'s self,
object: Object<'b>
) -> Result<Either<Present<Object<'b>>, Absent<Object<'b>>>, S3SyncError>
pub fn check_object_exists_list<'s, 'b>(
&'s self,
object: Object<'b>
) -> Result<Either<Present<Object<'b>>, Absent<Object<'b>>>, S3SyncError>
Checks if given object exists by listing objects.
Requires ListBucket
permission.
sourcepub fn list_objects<'b, 's: 'b>(
&'s self,
bucket: &'b Present<Bucket>,
prefix: String
) -> impl Iterator<Item = Result<Present<Object<'b>>, S3SyncError>> + Captures1<'s> + Captures2<'b>
pub fn list_objects<'b, 's: 'b>(
&'s self,
bucket: &'b Present<Bucket>,
prefix: String
) -> impl Iterator<Item = Result<Present<Object<'b>>, S3SyncError>> + Captures1<'s> + Captures2<'b>
Provides iterator of objects in existing bucket that have key of given prefix.
sourcepub fn get_body<'s, 'b>(
&'s self,
object: &Present<Object<'b>>
) -> Result<impl Read, S3SyncError>
pub fn get_body<'s, 'b>(
&'s self,
object: &Present<Object<'b>>
) -> Result<impl Read, S3SyncError>
Gets object body.
sourcepub fn put_object<'s, 'b>(
&'s self,
object: impl ExternalState<Object<'b>>,
body: impl Read,
meta: ObjectBodyMeta
) -> Result<Present<Object<'b>>, S3SyncError>
pub fn put_object<'s, 'b>(
&'s self,
object: impl ExternalState<Object<'b>>,
body: impl Read,
meta: ObjectBodyMeta
) -> Result<Present<Object<'b>>, S3SyncError>
Puts object with given body using multipart API.
If given existing object it will be overwritten.
Use .max_upload_size()
to find out how many bytes the body can have at maximum.
Increase part_size
to be able to upload more date (max_upload_size = part_number * 10_000
).
sourcepub fn delete_object<'b, 's: 'b>(
&'s self,
object: impl ExternalState<Object<'b>>
) -> Result<Absent<Object<'b>>, S3SyncError>
pub fn delete_object<'b, 's: 'b>(
&'s self,
object: impl ExternalState<Object<'b>>
) -> Result<Absent<Object<'b>>, S3SyncError>
Deletes single object.
Delete call does not fail if object does not exist and therefore this method can work with
Present
, Absent
or just Object
values.
To delete many objects it is better performance wise to use .delete_objects()
witch
uses bulk delete API.
sourcepub fn delete_objects<'b, 's: 'b>(
&'s self,
objects: impl IntoIterator<Item = impl ExternalState<Object<'b>>>
) -> impl Iterator<Item = Result<Vec<Result<Absent<Object<'b>>, (Object<'b>, S3SyncError)>>, S3SyncError>> + Captures1<'s> + Captures2<'b>
pub fn delete_objects<'b, 's: 'b>(
&'s self,
objects: impl IntoIterator<Item = impl ExternalState<Object<'b>>>
) -> impl Iterator<Item = Result<Vec<Result<Absent<Object<'b>>, (Object<'b>, S3SyncError)>>, S3SyncError>> + Captures1<'s> + Captures2<'b>
Deletes list of objects in streaming fashion using bulk delete API.
Note that if returned iterator is not completely consumed not all items from the list may be processed.
Delete call does not fail if object does not exist and therefore this method can work with
Present
, Absent
or just Object
values.
Objects can live in different buckets but for best performance it is recommended to order the list by bucket so that biggest batches can be crated.
Each returned item represent batch delete call to S3 API.
Successful batch call will return Ok
variant containing vector of results for each
individual object delete operation as provided by S3.
sourcepub fn object_present<'b, 's: 'b, R: Read + 's, F: FnOnce() -> Result<(R, ObjectBodyMeta), Error> + 's>(
&'s self,
object: Object<'b>,
check_impl: CheckObjectImpl,
body: F
) -> impl Ensure<Present<Object<'b>>, EnsureAction = impl Meet<Met = Present<Object<'b>>, Error = S3SyncError> + Captures1<'s> + Captures2<'b>> + Captures1<'s> + Captures2<'b>
pub fn object_present<'b, 's: 'b, R: Read + 's, F: FnOnce() -> Result<(R, ObjectBodyMeta), Error> + 's>(
&'s self,
object: Object<'b>,
check_impl: CheckObjectImpl,
body: F
) -> impl Ensure<Present<Object<'b>>, EnsureAction = impl Meet<Met = Present<Object<'b>>, Error = S3SyncError> + Captures1<'s> + Captures2<'b>> + Captures1<'s> + Captures2<'b>
Returns Ensure
object that can be used to ensure that object is present in the S3 bucket.
It will call body function to obtain Read
object from which the data will be uploaded to S3
and its meta data if object does not already exist there.
Note that there can be a race condition between check if object exists and upload.
sourcepub fn object_absent<'b, 's: 'b>(
&'s self,
object: Object<'b>,
check_impl: CheckObjectImpl
) -> impl Ensure<Absent<Object<'b>>, EnsureAction = impl Meet<Met = Absent<Object<'b>>, Error = S3SyncError> + Captures1<'s> + Captures2<'b>> + Captures1<'s> + Captures2<'b>
pub fn object_absent<'b, 's: 'b>(
&'s self,
object: Object<'b>,
check_impl: CheckObjectImpl
) -> impl Ensure<Absent<Object<'b>>, EnsureAction = impl Meet<Met = Absent<Object<'b>>, Error = S3SyncError> + Captures1<'s> + Captures2<'b>> + Captures1<'s> + Captures2<'b>
Returns Ensure
object that can be used to ensure that object is absent in the S3 bucket.
Note that there can be a race condition between check if object exists and delete operation.
Auto Trait Implementations
impl !RefUnwindSafe for S3
impl !Send for S3
impl !Sync for S3
impl Unpin for S3
impl !UnwindSafe for S3
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more