Skip to content

Commit

Permalink
Obey clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz Gies <[email protected]>
  • Loading branch information
Licenser committed May 22, 2024
1 parent 7728856 commit f84b1dd
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl Builder {
///
/// # Errors
/// If the dataset name is empty.
#[must_use]
pub fn with_dataset(mut self, dataset_name: impl Into<String>) -> Result<Self, Error> {
let dataset_name: String = dataset_name.into();
if dataset_name.is_empty() {
Expand All @@ -67,7 +66,6 @@ impl Builder {
///
/// # Errors
/// If the token is empty or does not start with `xaat-` (aka is not a api token).
#[must_use]
pub fn with_token(mut self, token: impl Into<String>) -> Result<Self, Error> {
let token: String = token.into();
if token.is_empty() {
Expand All @@ -84,7 +82,6 @@ impl Builder {
///
/// # Errors
/// If the URL is not a valid URL.
#[must_use]
pub fn with_url(mut self, url: &str) -> Result<Self, Error> {
self.url = Some(url.parse()?);
Ok(self)
Expand Down Expand Up @@ -136,22 +133,21 @@ impl Builder {
///
/// # Errors
/// If an environment variable is not valid UTF8, or any of their values are invalid.
#[must_use]
pub fn with_env(mut self) -> Result<Self, Error> {
if self.token.is_none() {
if let Some(t) = get_env("AXIOM_TOKEN")? {
self = self.with_token(t)?
self = self.with_token(t)?;
}
};

if self.dataset_name.is_none() {
if let Some(d) = get_env("AXIOM_DATASET")? {
self = self.with_dataset(d)?
self = self.with_dataset(d)?;
}
};
if self.url.is_none() {
if let Some(u) = get_env("AXIOM_URL")? {
self = self.with_url(&u)?
self = self.with_url(&u)?;
}
};

Expand All @@ -175,7 +171,7 @@ impl Builder {
let dataset_name = self.dataset_name.ok_or(Error::MissingDataset)?;
let url = self
.url
.unwrap_or_else(|| CLOUD_URL.to_string().parse().unwrap());
.unwrap_or_else(|| CLOUD_URL.to_string().parse().expect("this is a valid URL"));

let mut headers = HashMap::with_capacity(2);
headers.insert("Authorization".to_string(), format!("Bearer {token}"));
Expand Down

0 comments on commit f84b1dd

Please sign in to comment.