Struct lib_mal::ClientBuilder [−][src]
pub struct ClientBuilder { /* fields omitted */ }Expand description
Example
use lib_mal::ClientBuilder;
fn example() {
let client = ClientBuilder::new().secret("[YOUR_CLIENT_ID]".to_string()).access_token("exampleExAmPlE".to_string()).build_no_refresh();
}Implementations
Sets the client_secret
Example
let client =
ClientBuilder::new().secret("[YOUR_CLIENT_ID]".to_string()).build_no_refresh();
let another_client = ClientBuilder::new().secret(None).build_no_refresh();
Sets the directory the client will use to cache the tokens
Example
use std::path::PathBuf;
let client = ClientBuilder::new().cache_dir(PathBuf::new()).build_no_refresh();Sets the access token for the client
Example
let client =
ClientBuilder::new().access_token("exampleToKeN".to_string()).build_no_refresh();Sets wether or not the client should cache the tokens
Example
let client = ClientBuilder::new().caching(false).build_no_refresh();
Builds a MALClient without attempting to refresh the access token
Example
use lib_mal::ClientBuilder;
use std::path::PathBuf;
fn example() {
let client =
ClientBuilder::new().secret("[YOUR_CLIENT_ID]".to_string()).caching(true).cache_dir(PathBuf::new()).build_no_refresh();
}Builds a MALClient after attempting to refresh the access token from cache
Example
use lib_mal::ClientBuilder;
use lib_mal::MALError;
use std::path::PathBuf;
async fn example() -> Result<(), MALError> {
let client =
ClientBuilder::new().secret("[YOUR_CLIENT_ID]".to_string()).caching(true).cache_dir(PathBuf::new()).build_with_refresh().await?;
Ok(())
}