pub struct Manager { /* private fields */ }
Expand description
Implements AWS S3 manager.
Implementations§
Source§impl Manager
impl Manager
pub fn new(shared_config: &AwsSdkConfig) -> Self
Sourcepub async fn create_bucket(&self, s3_bucket: &str) -> Result<()>
pub async fn create_bucket(&self, s3_bucket: &str) -> Result<()>
Creates a S3 bucket.
Sourcepub async fn delete_bucket(&self, s3_bucket: &str) -> Result<()>
pub async fn delete_bucket(&self, s3_bucket: &str) -> Result<()>
Deletes a S3 bucket.
Sourcepub async fn delete_objects(
&self,
s3_bucket: Arc<String>,
prefix: Option<Arc<String>>,
) -> Result<()>
pub async fn delete_objects( &self, s3_bucket: Arc<String>, prefix: Option<Arc<String>>, ) -> Result<()>
Deletes objects by “prefix”. If “prefix” is “None”, empties a S3 bucket, deleting all files. ref. https://github.com/awslabs/aws-sdk-rust/blob/main/examples/s3/src/bin/delete-objects.rs
“If a single piece of data must be accessible from more than one task concurrently, then it must be shared using synchronization primitives such as Arc.” ref. https://tokio.rs/tokio/tutorial/spawning
Sourcepub async fn list_objects(
&self,
s3_bucket: Arc<String>,
prefix: Option<Arc<String>>,
) -> Result<Vec<Object>>
pub async fn list_objects( &self, s3_bucket: Arc<String>, prefix: Option<Arc<String>>, ) -> Result<Vec<Object>>
List objects in the bucket with an optional prefix, in the descending order of “last_modified” timestamps. “bucket_name” implies the suffix “/”, so no need to prefix sub-directory with “/”. Passing “bucket_name” + “directory” is enough!
e.g. “foo-mydatabucket” for bucket_name “mydata/myprefix/” for prefix
Sourcepub async fn put_object(
&self,
file_path: Arc<String>,
s3_bucket: Arc<String>,
s3_key: Arc<String>,
) -> Result<()>
pub async fn put_object( &self, file_path: Arc<String>, s3_bucket: Arc<String>, s3_key: Arc<String>, ) -> Result<()>
Writes an object to a S3 bucket using stream.
WARN: use stream! otherwise it can cause OOM – don’t do the following! “fs::read” reads all data onto memory “.body(ByteStream::from(contents))” passes the whole data to an API call
“If a single piece of data must be accessible from more than one task concurrently, then it must be shared using synchronization primitives such as Arc.” ref. https://tokio.rs/tokio/tutorial/spawning
Sourcepub async fn get_object(
&self,
s3_bucket: Arc<String>,
s3_key: Arc<String>,
file_path: Arc<String>,
) -> Result<()>
pub async fn get_object( &self, s3_bucket: Arc<String>, s3_key: Arc<String>, file_path: Arc<String>, ) -> Result<()>
Downloads an object from a S3 bucket using stream.
WARN: use stream! otherwise it can cause OOM – don’t do the following! “aws_smithy_http::byte_stream:ByteStream.collect” reads all the data into memory “File.write_all_buf(&mut bytes)” to write bytes
“If a single piece of data must be accessible from more than one task concurrently, then it must be shared using synchronization primitives such as Arc.” ref. https://tokio.rs/tokio/tutorial/spawning
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Manager
impl !RefUnwindSafe for Manager
impl Send for Manager
impl Sync for Manager
impl Unpin for Manager
impl !UnwindSafe for Manager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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