Struct Manager

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

Implements AWS S3 manager.

Implementations§

Source§

impl Manager

Source

pub fn new(shared_config: &AwsSdkConfig) -> Self

Source

pub async fn create_bucket(&self, s3_bucket: &str) -> Result<()>

Creates a S3 bucket.

Source

pub async fn delete_bucket(&self, s3_bucket: &str) -> Result<()>

Deletes a S3 bucket.

Source

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

Source

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

Source

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

Source

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

Source

pub async fn compress_seal_put_object( &self, envelope: Arc<Envelope>, file_path: Arc<String>, s3_bucket: Arc<String>, s3_key: Arc<String>, ) -> Result<()>

Compresses the file, encrypts, and uploads to S3.

Source

pub async fn get_object_unseal_decompress( &self, envelope: Arc<Envelope>, s3_bucket: Arc<String>, s3_key: Arc<String>, file_path: Arc<String>, ) -> Result<()>

Reverse of “compress_seal_put_object”.

Trait Implementations§

Source§

impl Clone for Manager

Source§

fn clone(&self) -> Manager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Manager

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,