soundcloud_rs/client/
builder.rs1use crate::models::client::Client;
2use crate::models::config::RetryConfig;
3use crate::models::error::Error;
4
5#[derive(Debug)]
6pub struct ClientBuilder {
7 retry_config: RetryConfig,
8}
9
10impl ClientBuilder {
11 pub fn new() -> Self {
13 Self {
14 retry_config: RetryConfig::default(),
15 }
16 }
17
18 pub fn with_max_retries(mut self, max_retries: u32) -> Self {
20 self.retry_config.max_retries = max_retries;
21 self
22 }
23
24 pub fn with_retry_on_401(mut self, retry_on_401: bool) -> Self {
26 self.retry_config.retry_on_401 = retry_on_401;
27 self
28 }
29
30 pub async fn build(self) -> Result<Client, Error> {
32 Client::with_retry_config(self.retry_config).await
33 }
34}
35
36impl Default for ClientBuilder {
37 fn default() -> Self {
38 Self::new()
39 }
40}
41