Releases: lmammino/lastfm
Releases · lmammino/lastfm
0.10.0
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
What's Changed
- Cloneable client by @bobertoyin in #9
New Contributors
- @bobertoyin made their first contribution in #9
Full Changelog: 0.8.1...0.9.0
0.8.1
- Added
default_features = false
toreqwest
to make changes in0.8.0
really work! -.-
Full Changelog: 0.8.0...0.8.1
0.8.0
- Added
rustls-tls
flag toreqwest
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
What's Changed
- make
RetryStrategy
sendable across threads by @duckfromdiscord in #8
New Contributors
- @duckfromdiscord made their first contribution in #8
Full Changelog: 0.6.1...0.7.0
0.6.1
0.6.0
What's Changed
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
What's Changed
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
What's Changed
- Allows proper chaining of methods
- simplify types by internally storing
username
andapi_key
as Strings and only acceptAsRef<str>
in the constructors - have
from_env
andtry_from_env
methods also inClientBuilder()
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
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