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

Creates a new ClientBuilder. All fields are set to None by default.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.