Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from typed-builder to bon #196

Merged
merged 18 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -3,20 +3,25 @@ use super::HttpError;
use crate::api_traits::AsyncTelegramApi;
use crate::api_traits::ErrorResponse;
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()
Veetaha marked this conversation as resolved.
Show resolved Hide resolved
)]
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,19 +1,20 @@
use super::Error;
use super::HttpError;
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