Struct imagevault::Client[][src]

pub struct Client<T: Authentication + Sync> {
    pub client_identity: String,
    pub client_secret: String,
    pub authentication: Option<Arc<Mutex<T>>>,
    pub reqwest_client: ReqwestClient,
    pub base_url: Url,
}
Expand description

Client

A client that is used to consume the ImageVault API.

Remarks

The client saves and mutates the authentication, so it is recommended to re-use the client as much as possible in order to minimize the need to re-authenticate.

Fields

client_identity: Stringclient_secret: Stringauthentication: Option<Arc<Mutex<T>>>reqwest_client: ReqwestClientbase_url: Url

Implementations

Creates a new Client

Arguments

  • client_identity - The client identity
  • client_secret - The client secret
  • base_url - The base URL to ImageVault, e.g. https://myimagevault.se

Adds authentication to the Client

Arguments

  • authentication - The Authentication to use

Remarks

Pretty much everything in the ImageVault API requires authentication, so this should be included most of the time.

Examples

use imagevault::{
    Client,
    authentication::ClientCredentialsAuthentication,
};

let authentication = ClientCredentialsAuthentication::default();

let client = Client::new(
    "identity",
    "secret",
    "https://myimagevault.local"
    )?
    .with_authentication(authentication);

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.

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.