pub mod bucket;
pub mod object;
pub mod region;
pub mod service;
mod error;
pub use error::Error;
pub(crate) mod sign_v4;
pub(crate) mod utils;
use bon::bon;
pub struct Client {
access_key_id: String,
access_key_secret: String,
endpoint: String,
region: String,
bucket: String,
http_client: reqwest::Client,
}
#[bon]
impl Client {
#[builder(on(String, into))]
pub fn new(
access_key_id: String,
access_key_secret: String,
endpoint: String,
region: String,
bucket: String,
) -> Self {
Self {
access_key_id,
access_key_secret,
endpoint,
region,
bucket,
http_client: reqwest::Client::new(),
}
}
pub fn set_bucket_info(
&mut self,
bucket: Option<&str>,
region: Option<&str>,
endpoint: Option<&str>,
) {
if let Some(s) = bucket {
s.clone_into(&mut self.bucket);
}
if let Some(s) = region {
s.clone_into(&mut self.region);
}
if let Some(s) = endpoint {
s.clone_into(&mut self.endpoint);
}
}
pub fn bucket(&self) -> &str {
&self.bucket
}
pub fn region(&self) -> &str {
&self.region
}
pub fn endpoint(&self) -> &str {
&self.endpoint
}
}