This commit is contained in:
Brent Schroeter 2025-09-16 19:43:59 -07:00
parent 751e88fdc4
commit 1d7d5c8a59
2 changed files with 4 additions and 21 deletions

View file

@ -18,32 +18,15 @@ pub struct Client {
token: String, token: String,
} }
// Implement the Default trait so that `derive_builder` will allow fields impl Client {
// containing the Client type to be defined with `#[builder(setter(skip))]`. pub fn new_from_access_token(token: &str) -> Result<Self, reqwest::Error> {
// Ok(Self {
// In order to avoid repeating ourselves, this may also be used in
// `new_from_access_token()`.
impl Default for Client {
/// WARNING: Default is implemented only to satisfy trait bound checks
/// internally. You may use it externally as a placeholder value, but be
/// aware that it will not be able to make any authenticated API requests.
fn default() -> Self {
Self {
api_root: DEFAULT_API_ROOT.to_owned(), api_root: DEFAULT_API_ROOT.to_owned(),
client: reqwest::ClientBuilder::default() client: reqwest::ClientBuilder::default()
.https_only(true) .https_only(true)
.build() .build()
.expect("reqwest client is always built with the same configuration here"), .expect("reqwest client is always built with the same configuration here"),
token: "".to_owned(),
}
}
}
impl Client {
pub fn new_from_access_token(token: &str) -> Result<Self, reqwest::Error> {
Ok(Self {
token: token.to_owned(), token: token.to_owned(),
..Default::default()
}) })
} }

View file

@ -45,7 +45,7 @@ pub struct CreateRecordsDetails {
pub reasons: Vec<String>, pub reasons: Vec<String>,
} }
impl<'a, T> CreateRecordsQuery<T> impl<T> CreateRecordsQuery<T>
where where
T: Clone + DeserializeOwned + Serialize, T: Clone + DeserializeOwned + Serialize,
{ {