docs_configuration/
docs_configuration.rs1use std::{num::NonZeroU32, time::Duration};
6
7use http::uri::Scheme;
8use s2_sdk::{
9 S2,
10 types::{BasinAuthority, RetryConfig, S2Config, S2Endpoints},
11};
12
13fn main() -> Result<(), Box<dyn std::error::Error>> {
14 {
16 let token = "local-token".to_string();
17 let endpoints = S2Endpoints::new(
19 "localhost:8080".parse()?,
20 BasinAuthority::Direct("localhost:8080".parse()?),
21 )
22 .with_scheme(Scheme::HTTP);
23
24 let client = S2::new(S2Config::new(token).with_endpoints(endpoints))?;
25 println!("Created client with custom endpoints: {:?}", client);
27 }
28
29 {
31 let token = std::env::var("S2_ACCESS_TOKEN").unwrap_or_else(|_| "demo".into());
32 let client = S2::new(
34 S2Config::new(token).with_retry(
35 RetryConfig::new()
36 .with_max_attempts(NonZeroU32::new(5).unwrap())
37 .with_min_base_delay(Duration::from_millis(100))
38 .with_max_base_delay(Duration::from_secs(2)),
39 ),
40 )?;
41 println!("Created client with retry config: {:?}", client);
43 }
44
45 {
47 let token = std::env::var("S2_ACCESS_TOKEN").unwrap_or_else(|_| "demo".into());
48 let client = S2::new(
50 S2Config::new(token)
51 .with_connection_timeout(Duration::from_secs(5))
52 .with_request_timeout(Duration::from_secs(10)),
53 )?;
54 println!("Created client with timeout config: {:?}", client);
56 }
57
58 Ok(())
59}