pub struct ConfigBuilder { /* private fields */ }Expand description
Configuration builder for creating a Config instance
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn build_client(self) -> Result<LastFmClient>
pub fn build_client(self) -> Result<LastFmClient>
Build a LastFmClient directly from this builder
This is equivalent to calling build().map(LastFmClient::from_config).
§Errors
Returns an error if the builder is missing required fields (e.g., API key).
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn api_key(self, key: impl Into<String>) -> Self
pub fn api_key(self, key: impl Into<String>) -> Self
Set the API key
§Example
use lastfm_client::ConfigBuilder;
let builder = ConfigBuilder::new().api_key("my_api_key");Sourcepub fn user_agent(self, agent: impl Into<String>) -> Self
pub fn user_agent(self, agent: impl Into<String>) -> Self
Set the user agent
If not set, defaults to async_lastfm/VERSION
Sourcepub fn timeout(self, duration: Duration) -> Self
pub fn timeout(self, duration: Duration) -> Self
Set the request timeout
If not set, defaults to 30 seconds
Sourcepub fn max_concurrent_requests(self, max: usize) -> Self
pub fn max_concurrent_requests(self, max: usize) -> Self
Set maximum concurrent requests
If not set, defaults to 5
Sourcepub fn retry_attempts(self, attempts: u32) -> Self
pub fn retry_attempts(self, attempts: u32) -> Self
Set number of retry attempts
If not set, defaults to 3
Sourcepub fn rate_limit(self, max_requests: u32, per_duration: Duration) -> Self
pub fn rate_limit(self, max_requests: u32, per_duration: Duration) -> Self
Set rate limiting
§Example
use lastfm_client::ConfigBuilder;
use std::time::Duration;
let builder = ConfigBuilder::new()
.api_key("key")
.rate_limit(5, Duration::from_secs(1)); // Max 5 requests per secondSourcepub fn build(self) -> Result<Config>
pub fn build(self) -> Result<Config>
Build the configuration
§Errors
Returns an error if the API key is not set and cannot be loaded from environment
Sourcepub fn build_with_defaults() -> Result<Config>
pub fn build_with_defaults() -> Result<Config>
Build the configuration with defaults, trying to load API key from environment
This is equivalent to ConfigBuilder::new().build() but more explicit about
the default behavior.
§Errors
Returns an error if the API key is not set and cannot be loaded from environment