Skip to content

Releases: lmammino/lastfm

0.10.0

05 May 18:12
Compare
Choose a tag to compare

What's Changed

  • return newer tracks first in RecentTracksFetcher.into_stream by @bobertoyin in #10

Full Changelog: 0.9.0...0.10.0

0.9.0

05 May 17:28
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 0.8.1...0.9.0

0.8.1

26 Jan 23:16
Compare
Choose a tag to compare
  • Added default_features = false to reqwest to make changes in 0.8.0 really work! -.-

Full Changelog: 0.8.0...0.8.1

0.8.0

26 Jan 23:11
Compare
Choose a tag to compare
  • Added rustls-tls flag to reqwest to make it easier to use this libraries in context where sys libraries are not consistently available (such as AWS Lambda)

Full Changelog: 0.7.0...0.8.0

0.7.0

28 Dec 14:54
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 0.6.1...0.7.0

0.6.1

12 Sep 09:03
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.6.0...0.6.1

0.6.0

12 Sep 09:00
Compare
Choose a tag to compare

What's Changed

  • BREAKING CHANGE: use typed-builder to implement client builder by @lmammino in #5

Now the way to construct a client is:

use lastfm::Client;

let client = Client::builder()
  .api_key("YOUR_API_KEY")
  .username("YOUR_USERNAME")
  .build();

If you want to load your API key from env:

use lastfm::Client;

let client = Client::<String, &str>::from_env("YOUR_USERNAME");

Full Changelog: 0.5.0...0.6.0

0.5.0

04 Jun 22:40
Compare
Choose a tag to compare

What's Changed

  • Makes retry logic configurable by @lmammino in #4
  • Better API documentation
  • More examples

Example of custom retry logic

use lastfm::{retry_strategy::RetryStrategy, ClientBuilder};
use std::time::Duration;

/// A retry strategy that will retry 3 times with the following delays:
/// - Retry 0: 0 second delay
/// - Retry 1: 1 second delay
/// - Retry 2: 2 seconds delay
struct SimpleRetryStrategy {}

impl RetryStrategy for SimpleRetryStrategy {
    fn should_retry_after(&self, attempt: usize) -> Option<std::time::Duration> {
        // if retrying more than 3 times stop
        if attempt >= 3 {
            return None;
        }

        // otherwise wait a second per number of attempts
        Some(Duration::from_secs(attempt as u64))
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let retry_strategy = SimpleRetryStrategy {};

    let client = ClientBuilder::new("some-api-key", "loige")
        .retry_strategy(Box::from(retry_strategy))
        .build();

    // do something with client...
    dbg!(client);

    Ok(())
}

Full Changelog: 0.4.0...0.5.0

0.4.0

24 Apr 09:36
Compare
Choose a tag to compare

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

0.3.0

23 Apr 23:23
Compare
Choose a tag to compare

What's Changed

You can now customise your client and bring your own reqwest client (to configure you own custom timeouts or headers) and change the default base URL (e.g. for local testing)

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();

    // do something with client...

    Ok(())
}

Full Changelog: 0.2.0...0.3.0