pub struct S3Service { /* private fields */ }
Expand description
S3 service for interacting with AWS S3
This service provides a high-level interface for S3 operations with dependency injection for better performance and testability.
Implementations§
Source§impl S3Service
impl S3Service
Sourcepub fn with_client(client: Client) -> Self
pub fn with_client(client: Client) -> Self
Sourcepub fn with_config(config: &SdkConfig) -> Self
pub fn with_config(config: &SdkConfig) -> Self
Sourcepub async fn get_object(&self, bucket: &str, key: &str) -> Result<Vec<u8>>
pub async fn get_object(&self, bucket: &str, key: &str) -> Result<Vec<u8>>
Get an S3 object
§Arguments
bucket
- Name of the S3 bucket.key
- Object key within the bucket.
§Returns
The object contents as a Vec<u8>
.
§Errors
S3Error::Service
- If the S3 client fails to create.S3Error::Timeout
- If the request times out.S3Error::Transport
- If the request fails to dispatch.S3Error::Build
- If the request fails to build.
Sourcepub async fn put_object(
&self,
bucket: &str,
key: &str,
value: impl Into<ByteStream>,
content_type: Option<&str>,
) -> Result<()>
pub async fn put_object( &self, bucket: &str, key: &str, value: impl Into<ByteStream>, content_type: Option<&str>, ) -> Result<()>
Put an S3 object
§Arguments
bucket
- The bucket of the object to putkey
- The key of the object to putvalue
- The value of the object to putcontent_type
- The content type of the object
§Returns
Returns Ok(())
if the object is put successfully.
§Errors
S3Error::Service
- If the S3 client fails to create.S3Error::Timeout
- If the request times out.S3Error::Transport
- If the request fails to dispatch.S3Error::Build
- If the request fails to build.
Auto Trait Implementations§
impl Freeze for S3Service
impl !RefUnwindSafe for S3Service
impl Send for S3Service
impl Sync for S3Service
impl Unpin for S3Service
impl !UnwindSafe for S3Service
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
Mutably borrows from an owned value. Read more
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>
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 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>
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 moreCreates a shared type from an unshared type.