Struct ddmw_client::auth::Auth[][src]

pub struct Auth {
    pub name: Option<String>,
    pub pass_file: Option<String>,
    pub pass: Option<String>,
    pub token_file: Option<String>,
    pub token: Option<String>,
}
Expand description

Authentication context used to signal how to authenticate a connection.

Fields

name: Option<String>

Account name used to authenticate.

pass_file: Option<String>

Load raw account passphrase from the specified filename.

pass: Option<String>

Raw account passphrase to authenticate with. Only used if name has been set.

token_file: Option<String>

Use the specified file for authentication token storage.

token: Option<String>

Authentication token.

Implementations

Return true if there’s either a raw passphrase set in pass or a passphrase file has beeen set in pass_file. This function does not validate if the passphrase file exists or is accessible.

Get passphrase.

Return the raw pass field if set. Otherwise, load the pass_file if set, and return error if the passphrase could not be loaded from the file.

If neither pass nor pass_file have been set, return an error.

Get authentication token.

Return the raw token field if set. Otherwise, check if token_file is set. If it is, then attempt to load the token from it. If the file does not exist, then:

  • Return Ok(None) if account name and pass(file) have been set.
  • Return error if account name has not been set.

Helper function for authenticating a connection.

Authenticates the connection specified in conn, using the credentials stored in the Auth buffer using the following logic:

  1. If a raw token has been supplied in the token field, then attempt to authenticate with it and return the results.
  2. If a token_file has been been set, then:
    • If the file exists, try to load the authentication token, authenticate with it, and return the results.
    • If the file does not exist, then:
      • If account name and/or passphrase have not been set, then return error.
      • If account name and passphrase have been set, then continue.
  3. Make sure that an account name and a passphrase has been set. The passphrase is either set from the pass field or by loading the contents of the file in pass_file. Return error account name or passphrase can not be acquired.
  4. Authenticate using account name and passphrase. If a token_file was specified, then request an authentication token and store it in token_file on success. Return error on failure.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

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.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.