Skip to content

Commit

Permalink
Migrate from typed-builder to bon (#196)
Browse files Browse the repository at this point in the history
* Migrate from `typed-builder` to `bon`

Co-authored-by: EdJoPaTo <[email protected]>

---------

Co-authored-by: EdJoPaTo <[email protected]>
  • Loading branch information
Veetaha and EdJoPaTo authored Sep 11, 2024
1 parent 0cd7089 commit 2dc02ab
Show file tree
Hide file tree
Showing 5 changed files with 695 additions and 1,379 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ required-features = ["telegram-trait"]

[dependencies]
thiserror = "1"
typed-builder = "0.19"
bon = "2.2.0"

[dependencies.async-trait]
version = "0.1"
Expand Down
13 changes: 9 additions & 4 deletions src/api/async_telegram_api_impl.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
use super::Error;
use crate::api_traits::AsyncTelegramApi;
use async_trait::async_trait;
use bon::Builder;
use reqwest::multipart;
use serde_json::Value;
use std::path::PathBuf;
use std::time::Duration;
use tokio::fs::File;
use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder)]
#[derive(Debug, Clone, Builder)]
#[must_use = "API needs to be used in order to be useful"]
pub struct AsyncApi {
#[builder(setter(into))]
#[builder(into)]
pub api_url: String,

#[builder(
default_code = "reqwest::ClientBuilder::new().connect_timeout(Duration::from_secs(10)).timeout(Duration::from_secs(500)).build().unwrap()"
default = reqwest::ClientBuilder::new()
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(500))
.build()
.unwrap()
)]
pub client: reqwest::Client,
}
Expand Down
9 changes: 5 additions & 4 deletions src/api/telegram_api_impl.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use super::Error;
use crate::api_traits::TelegramApi;
use bon::Builder;
use multipart::client::lazy::Multipart;
use serde_json::Value;
use std::path::PathBuf;
use std::time::Duration;
use typed_builder::TypedBuilder;
use ureq::Response;

#[derive(Debug, Clone, TypedBuilder)]
#[derive(Debug, Clone, Builder)]
#[must_use = "API needs to be used in order to be useful"]
pub struct Api {
#[builder(setter(into))]
#[builder(into)]
pub api_url: String,
#[builder(default_code = "ureq::builder().timeout(Duration::from_secs(500)).build()")]

#[builder(default = ureq::builder().timeout(Duration::from_secs(500)).build())]
pub request_agent: ureq::Agent,
}

Expand Down
Loading

0 comments on commit 2dc02ab

Please sign in to comment.