Skip to content

0.4.0

Compare
Choose a tag to compare
@lmammino lmammino released this 24 Apr 09:36
· 15 commits to main since this release

What's Changed

  • Refactor builder pattern for ClientBuilder by @lmammino in #3
  • Allows proper chaining of methods
  • simplify types by internally storing username and api_key as Strings and only accept AsRef<str> in the constructors
  • have from_env and try_from_env methods also in ClientBuilder()

Breaking changes

The ClientBuilder now allows for proper chaining of methods:

use lastfm::ClientBuilder;
use std::env;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = env::var("LASTFM_API_KEY")?;

-    let mut client_builder = ClientBuilder::new(api_key, "loige".to_string());
-    client_builder.reqwest_client(reqwest::Client::new());
-    client_builder.base_url("http://localhost:8080".parse().unwrap());
-    let client = client_builder.build();
+    let client = ClientBuilder::new(api_key, "loige")
+        .reqwest_client(reqwest::Client::new())
+        .base_url("http://localhost:8080".parse().unwrap())
+        .build();

    // do something with client...

    Ok(())
}

Full Changelog: 0.3.0...0.4.0