Struct aws_manager::s3::Manager
source · [−]pub struct Manager { /* private fields */ }
Expand description
Implements AWS S3 manager.
Implementations
sourceimpl 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 !RefUnwindSafe for Manager
impl Send for Manager
impl Sync for Manager
impl Unpin for Manager
impl !UnwindSafe for Manager
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more