Struct AsyncScramClient

Source
pub struct AsyncScramClient<S: ScramHashing, A: AsyncScramAuthClient + Sync, B: AsyncScramCbHelper> { /* private fields */ }
Expand description

§A Scram Client

S: ScramHashing a developer should manually preprogram the ScramHashing for every supported by their’s program types of auth.
A: AsyncScramAuthClient a developes should attach a AsyncScramAuthClient trait to his implementation where the username and password are stored or implement one.

If a developer which to use a channel bind then developer should find out how to extract endpoint certificate from his TLS connection. i.e native_tls::TlsStream::tls_server_end_point()

Implementations§

Source§

impl<S: ScramHashing, A: AsyncScramAuthClient + Sync, B: AsyncScramCbHelper> AsyncScramClient<S, A, B>

Source

pub fn new( scram_auth_cli: A, scram_nonce: ScramNonce, chan_bind_type: ChannelBindType, chan_bind_helper: B, ignore_exts: bool, ) -> ScramResult<AsyncScramClient<S, A, B>>

Creates a new client instance with borrowed arguments. Sets all fields to default instance.

§Arguments
  • scram_auth_cli - an authentification instance which implements [ScramAuthClient]

  • scram_nonce - a client scram nonce ScramNonce

  • chan_bind_type - picks the channel bound ChannelBindType. It is responsibility of the developer to correctly set the chan binding type.

  • chan_bind_helper - a data type which implements a traint [ScramCbHelper] which contains functions for realization which are designed to provide the channel bind data to the SCRAM crate.

§Examples
let cbt = ChannelBindType::None;

let ac = AuthClient::new(username, password);
let nonce = ScramNonce::Plain(&client_nonce_dec);

let scram_res = SyncScramClient::<ScramSha256, AuthClient, AuthClient>::new(&ac, nonce, cbt, &ac);
Source

pub fn is_completed(&self) -> bool

Checks if the client authentification was completed successfully.

Source

pub async fn init_client(&mut self) -> ScramResultClient

Initializes the SCRAM negoatiation from client

§Arguments
  • to_base64 - when set to true, the generated response will be encoded to base64.
§Returns
  • base64 encoded or plain string with formed message
Source

pub async fn parse_response_base64<T: AsRef<[u8]>>( &mut self, input: T, ) -> ScramResult<ScramResultClient>

Decodes the response from server which is in base64 encoded and performes parsing and result computation.

§Arguments
  • input - a base64 encoded response from server
§Returns
Source

pub async fn parse_response( &mut self, resp: &str, ) -> ScramResult<ScramResultClient>

Performes parsing of the response from server and result computation.
It is assumed that resp is UTF-8 valid sequences

§Arguments
  • resp - A response from client as ref str.

  • to_base64 - if set to true, will encode response into base64.

§Returns

Auto Trait Implementations§

§

impl<S, A, B> Freeze for AsyncScramClient<S, A, B>
where A: Freeze, B: Freeze,

§

impl<S, A, B> RefUnwindSafe for AsyncScramClient<S, A, B>

§

impl<S, A, B> Send for AsyncScramClient<S, A, B>
where A: Send, B: Send, S: Send,

§

impl<S, A, B> Sync for AsyncScramClient<S, A, B>
where S: Sync,

§

impl<S, A, B> Unpin for AsyncScramClient<S, A, B>
where A: Unpin, B: Unpin, S: Unpin,

§

impl<S, A, B> UnwindSafe for AsyncScramClient<S, A, B>
where A: UnwindSafe, B: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.