Struct ControllerBuilder

Source
pub struct ControllerBuilder<R: RngCore + Clone, D: Digest + FixedOutputReset> { /* private fields */ }

Implementations§

Source§

impl<R: RngCore + Clone, D: Digest + FixedOutputReset> ControllerBuilder<R, D>

Source

pub fn new() -> ControllerBuilder<R, D>

Source

pub fn finalize(self) -> Result<PrefixedApiKeyController<R, D>, BuilderError>

Finishes building the controller, returning Err if any necessary configs are missing.

Source

pub fn default_lengths(self) -> Self

Helper for setting the default short and long token length based on the defaults set in the typescript version Prefixed API Key module.

Source

pub fn prefix(self, prefix: String) -> Self

Sets the token prefix. This should be the name of your company or organization.

Source

pub fn rng(self, rng: R) -> Self

Sets an rng source that implements RngCore, which will be used for generating bytes used in the short and long tokens of the key.

Source

pub fn short_token_prefix(self, short_token_prefix: Option<String>) -> Self

An optional prefix for the short tokens. The length of this value should be less than the value you set for the short_token_length, and should leave enough space to avoid collisions with other short tokens.

Default: None

Source

pub fn short_token_length(self, short_token_length: usize) -> Self

The length of the short token

Source

pub fn long_token_length(self, long_token_length: usize) -> Self

The length of the secret long token

Source§

impl<D: Digest + FixedOutputReset + Clone> ControllerBuilder<OsRng, D>

Source

pub fn rng_osrng(self) -> Self

Helper function for configuring the Controller with an instance of OsRng.

Warning: The RNG you pick is an important decision. Please familiarize yourself with the types of RNGs, and then read the descriptions of each of the RNGs provided in the rand crate to determine the most appropriate RNG for your use case.

Source§

impl<D: Digest + FixedOutputReset + Clone> ControllerBuilder<ThreadRng, D>

Source

pub fn rng_threadrng(self) -> Self

Helper function for configuring the Controller with an instance of ThreadRng created by calling default.

Warning: The RNG you pick is an important decision. Please familiarize yourself with the types of RNGs, and then read the descriptions of each of the RNGs provided in the rand crate to determine the most appropriate RNG for your use case.

Source§

impl<D: Digest + FixedOutputReset + Clone> ControllerBuilder<StdRng, D>

Source

pub fn rng_stdrng(self) -> Self

Helper function for configuring the Controller with an instance of StdRng created by calling from_entropy.

Warning: The RNG you pick is an important decision. Please familiarize yourself with the types of RNGs, and then read the descriptions of each of the RNGs provided in the rand crate to determine the most appropriate RNG for your use case.

Source§

impl ControllerBuilder<OsRng, Sha256>

Source

pub fn seam_defaults(self) -> Self

Helper function for configuring the Controller with a new Sha256 instance

Requires the “sha2” feature

Source§

impl<R: RngCore + Clone> ControllerBuilder<R, Sha224>

Source

pub fn digest_sha224(self) -> Self

Helper function for configuring the Controller with a new Sha224 instance

Requires the “sha2” feature

Source§

impl<R: RngCore + Clone> ControllerBuilder<R, Sha256>

Source

pub fn digest_sha256(self) -> Self

Helper function for configuring the Controller with a new Sha256 instance

Requires the “sha2” feature

Source§

impl<R: RngCore + Clone> ControllerBuilder<R, Sha384>

Source

pub fn digest_sha384(self) -> Self

Helper function for configuring the Controller with a new Sha384 instance

Requires the “sha2” feature

Source§

impl<R: RngCore + Clone> ControllerBuilder<R, Sha512>

Source

pub fn digest_sha512(self) -> Self

Helper function for configuring the Controller with a new Sha512 instance

Requires the “sha2” feature

Source§

impl<R: RngCore + Clone> ControllerBuilder<R, Sha512_224>

Source

pub fn digest_sha512_224(self) -> Self

Helper function for configuring the Controller with a new Sha512_224 instance

Requires the “sha2” feature

Source§

impl<R: RngCore + Clone> ControllerBuilder<R, Sha512_256>

Source

pub fn digest_sha512_256(self) -> Self

Helper function for configuring the Controller with a new Sha512_256 instance

Requires the “sha2” feature

Trait Implementations§

Source§

impl<R: RngCore + Clone, D: Digest + FixedOutputReset + Clone> Default for ControllerBuilder<R, D>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<R, D> Freeze for ControllerBuilder<R, D>
where R: Freeze,

§

impl<R, D> RefUnwindSafe for ControllerBuilder<R, D>

§

impl<R, D> Send for ControllerBuilder<R, D>
where R: Send, D: Send,

§

impl<R, D> Sync for ControllerBuilder<R, D>
where R: Sync, D: Sync,

§

impl<R, D> Unpin for ControllerBuilder<R, D>
where R: Unpin, D: Unpin,

§

impl<R, D> UnwindSafe for ControllerBuilder<R, D>
where R: UnwindSafe, D: 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V