pub struct ClientBuilder { /* private fields */ }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§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn secret(self, secret: impl Into<Option<String>>) -> Self
pub fn secret(self, secret: impl Into<Option<String>>) -> Self
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();
Sourcepub fn cache_dir(self, path: impl Into<Option<PathBuf>>) -> Self
pub fn cache_dir(self, path: impl Into<Option<PathBuf>>) -> Self
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();Sourcepub fn access_token(self, token: impl Into<Option<String>>) -> Self
pub fn access_token(self, token: impl Into<Option<String>>) -> Self
Sets the access token for the client
§Example
let client =
ClientBuilder::new().access_token("exampleToKeN".to_string()).build_no_refresh();Sourcepub fn caching(self, caching: bool) -> Self
pub fn caching(self, caching: bool) -> Self
Sets wether or not the client should cache the tokens
§Example
let client = ClientBuilder::new().caching(false).build_no_refresh();
Sourcepub fn build_no_refresh(self) -> MALClient
pub fn build_no_refresh(self) -> MALClient
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();
}Sourcepub async fn build_with_refresh(self) -> Result<MALClient, MALError>
pub async fn build_with_refresh(self) -> Result<MALClient, MALError>
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(())
}Auto Trait Implementations§
impl Freeze for ClientBuilder
impl RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
impl UnwindSafe for ClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more