pub struct BaseExecutor<'a> { /* private fields */ }Expand description
An executor builds the S3 request.
use hyper::Method;
use bytes::Bytes;
use reqwest::Response;
use minio_rsc::Minio;
use minio_rsc::error::Result;
async fn get_object(minio:Minio)-> Result<Response> {
let executor = minio.executor(Method::GET);
let res: Response = executor
.bucket_name("bucket")
.object_name("test.txt")
.query("versionId", "cdabf31a-9752-4265-b137-6b3961fbaf9b")
.send_ok()
.await?;
Ok(res)
}
async fn put_object(minio:Minio, data:Bytes)-> Result<()> {
let executor = minio.executor(Method::PUT);
let res: Response = executor
.bucket_name("bucket")
.object_name("test.txt")
.body(data)
.send_ok()
.await?;
Ok(())
}Implementations§
Source§impl<'a> BaseExecutor<'a>
impl<'a> BaseExecutor<'a>
pub fn new(method: Method, client: &'a Minio) -> Self
Sourcepub fn bucket_name<T: Into<String>>(self, name: T) -> Self
pub fn bucket_name<T: Into<String>>(self, name: T) -> Self
Set the bucket name.
Sourcepub fn object_name<T: Into<String>>(self, name: T) -> Self
pub fn object_name<T: Into<String>>(self, name: T) -> Self
Set the object name.
Sourcepub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
pub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Inserts a key-value pair into the request header.
Sourcepub fn headers_merge(self, header: HeaderMap) -> Self
pub fn headers_merge(self, header: HeaderMap) -> Self
Merge header into request header.
Sourcepub fn headers_merge2(self, header: Option<HeaderMap>) -> Self
pub fn headers_merge2(self, header: Option<HeaderMap>) -> Self
Merge header into request header.
Sourcepub fn querys_merge(self, querys: QueryMap) -> Self
pub fn querys_merge(self, querys: QueryMap) -> Self
Merge querys into request query.
Sourcepub fn query<K: Into<String>, V: Into<String>>(self, key: K, value: V) -> Self
pub fn query<K: Into<String>, V: Into<String>>(self, key: K, value: V) -> Self
Inserts a key-value pair into the query map.
Sourcepub fn query_string(self, query_str: &str) -> Self
pub fn query_string(self, query_str: &str) -> Self
Inserts query_string into the query map.
pub fn apply<F>(self, apply: F) -> Selfwhere
F: FnOnce(Self) -> Self,
Sourcepub async fn send(self) -> Result<Response>
pub async fn send(self) -> Result<Response>
Send an HTTP request to S3 and return a Result<Response>.
note: this is just a response from the s3 service, probably a wrong response.
Sourcepub async fn send_ok(self) -> Result<Response>
pub async fn send_ok(self) -> Result<Response>
Send an HTTP request to S3 and return a Result<Response>.
This checks if the request is a legitimate S3 response.
Sourcepub async fn send_text_ok(self) -> Result<String>
pub async fn send_text_ok(self) -> Result<String>
Send an HTTP request to S3 and return a Result<String>.
This checks if the request is a legitimate S3 response.
Auto Trait Implementations§
impl<'a> !Freeze for BaseExecutor<'a>
impl<'a> !RefUnwindSafe for BaseExecutor<'a>
impl<'a> Send for BaseExecutor<'a>
impl<'a> Sync for BaseExecutor<'a>
impl<'a> Unpin for BaseExecutor<'a>
impl<'a> !UnwindSafe for BaseExecutor<'a>
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