pub struct ClientBuilder { /* private fields */ }
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
pub fn signature_type(self, st: SignatureType) -> ClientBuilder
pub fn security_providers(self, sps: Vec<SecurityHolder>) -> ClientBuilder
Sourcepub fn endpoint<S: ToString>(self, value: S) -> ClientBuilder
pub fn endpoint<S: ToString>(self, value: S) -> ClientBuilder
节点,支持以下三种格式:
- http://your-endpoint
- https://your-endpoint
- your-endpoint
Examples found in repository?
examples/obs.rs (line 18)
11async fn main()->Result<(), ObsError> {
12 dotenvy::dotenv().unwrap();
13
14 let ak = env::var("OBS_AK").unwrap();
15 let sk = env::var("OBS_SK").unwrap();
16 // println!("ak:{},sk:{}",&ak,&sk);
17 let obs = client::Client::builder()
18 .endpoint("https://obs.ap-southeast-1.myhuaweicloud.com")
19 .security_provider(&ak, &sk) //ifree-test
20 .build()?;
21 let key= "test.jpeg";
22 let bytes = obs.get_object("bucket", key).await?;
23
24 let mut file = std::fs::File::create("test.jpeg").unwrap();
25 file.write_all(&bytes).unwrap();
26
27 Ok(())
28}
Sourcepub fn security_provider<S: ToString>(self, ak: S, sk: S) -> ClientBuilder
pub fn security_provider<S: ToString>(self, ak: S, sk: S) -> ClientBuilder
Examples found in repository?
examples/obs.rs (line 19)
11async fn main()->Result<(), ObsError> {
12 dotenvy::dotenv().unwrap();
13
14 let ak = env::var("OBS_AK").unwrap();
15 let sk = env::var("OBS_SK").unwrap();
16 // println!("ak:{},sk:{}",&ak,&sk);
17 let obs = client::Client::builder()
18 .endpoint("https://obs.ap-southeast-1.myhuaweicloud.com")
19 .security_provider(&ak, &sk) //ifree-test
20 .build()?;
21 let key= "test.jpeg";
22 let bytes = obs.get_object("bucket", key).await?;
23
24 let mut file = std::fs::File::create("test.jpeg").unwrap();
25 file.write_all(&bytes).unwrap();
26
27 Ok(())
28}
pub fn timeout(self, duration: Duration) -> ClientBuilder
pub fn region<S: ToString>(self, value: S) -> ClientBuilder
pub fn is_secure(self, value: bool) -> ClientBuilder
Sourcepub fn build(self) -> Result<Client, ObsError>
pub fn build(self) -> Result<Client, ObsError>
Examples found in repository?
examples/obs.rs (line 20)
11async fn main()->Result<(), ObsError> {
12 dotenvy::dotenv().unwrap();
13
14 let ak = env::var("OBS_AK").unwrap();
15 let sk = env::var("OBS_SK").unwrap();
16 // println!("ak:{},sk:{}",&ak,&sk);
17 let obs = client::Client::builder()
18 .endpoint("https://obs.ap-southeast-1.myhuaweicloud.com")
19 .security_provider(&ak, &sk) //ifree-test
20 .build()?;
21 let key= "test.jpeg";
22 let bytes = obs.get_object("bucket", key).await?;
23
24 let mut file = std::fs::File::create("test.jpeg").unwrap();
25 file.write_all(&bytes).unwrap();
26
27 Ok(())
28}
Trait Implementations§
Source§impl Debug for ClientBuilder
impl Debug for ClientBuilder
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnwindSafe for ClientBuilder
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