pub struct SignerBuilder<'a, Kid, Pk, Body, Method, Path> { /* private fields */ }
Expand description

Builder to generate a Tl-Signature header value.

§Example

let tl_signature = truelayer_signing::SignerBuilder::build_with_pem(kid, private_key)
    .method(truelayer_signing::Method::Post)
    .path("/payouts")
    .header("Idempotency-Key", idempotency_key)
    .body(body)
    .build_signer()
    .sign()?;

Implementations§

source§

impl<'a> SignerBuilder<'a, Unset, Unset, Unset, Unset, Unset>

source

pub fn new() -> Self

source§

impl<'a> SignerBuilder<'a, &'a str, &'a [u8], Unset, Unset, Unset>

source

pub fn build_with_pem(kid: &'a str, private_key: &'a [u8]) -> Self

source§

impl<'a, Pk, Body, Method, Path> SignerBuilder<'a, Unset, Pk, Body, Method, Path>

source

pub fn kid(self, kid: &str) -> SignerBuilder<'a, &str, Pk, Body, Method, Path>

Add the private key kid.

source§

impl<'a, K, Body, Method, Path> SignerBuilder<'a, K, Unset, Body, Method, Path>

source

pub fn private_key( self, private_key: &[u8] ) -> SignerBuilder<'a, K, &[u8], Body, Method, Path>

Add the private key.

source§

impl<'a, K, Pk, Method, Path> SignerBuilder<'a, K, Pk, Unset, Method, Path>

source

pub fn body(self, body: &[u8]) -> SignerBuilder<'a, K, Pk, &[u8], Method, Path>

Add the full request body.

Note: This must be identical to what is sent with the request.

source§

impl<'a, K, Pk, Body, Path> SignerBuilder<'a, K, Pk, Body, Unset, Path>

source

pub fn method( self, method: Method ) -> SignerBuilder<'a, K, Pk, Body, Method, Path>

Add the request method.

source§

impl<'a, K, Pk, Body, Method> SignerBuilder<'a, K, Pk, Body, Method, Unset>

source

pub fn path(self, path: &str) -> SignerBuilder<'a, K, Pk, Body, Method, &str>

Add the request absolute path starting with a leading / and without any trailing slashes.

source§

impl<'a, K, Pk, Body, Method, Path> SignerBuilder<'a, K, Pk, Body, Method, Path>

source

pub fn header(self, key: &'a str, value: &'a [u8]) -> Self

Add a header name & value. May be called multiple times to add multiple different headers.

Warning: Only a single value per header name is supported.

source

pub fn headers( self, headers: impl IntoIterator<Item = (&'a str, &'a [u8])> ) -> Self

Appends multiple header names & values.

Warning: Only a single value per header name is supported.

source

pub fn jku(self, jku: &'a str) -> Self

Sets the jws header jku JSON Web Key URL.

Note: This is not generally required when calling APIs, but is set on webhook signatures.

source§

impl<'a> SignerBuilder<'a, &'a str, Unset, &'a [u8], Method, &'a str>

source

pub fn build_custom_signer(self) -> CustomSigner<'a>

Builds a CustomSigner

requires the kid, body, method, and path to be set to call this function. if the private key is set this function will not be available.

source§

impl<'a> SignerBuilder<'a, &'a str, &'a [u8], &'a [u8], Unset, Unset>

source

pub fn build_v1_signer(self) -> SignerV1<'a>

Build a V1 Signer see [SignerV1].

requires the private key, kid, and body to be set to call this function. if the method of path is set this function will not be available.

In general full request signing should be preferred, see Signer.

source§

impl<'a> SignerBuilder<'a, &'a str, &'a [u8], &'a [u8], Method, &'a str>

source

pub fn build_signer(self) -> Signer<'a>

Build a V2 Signer see Signer.

requires the private key, kid, body, method, and path to be set to call this function.

Trait Implementations§

source§

impl<Kid, Pk, Body, Method, Path> Debug for SignerBuilder<'_, Kid, Pk, Body, Method, Path>

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, Kid: Default, Pk: Default, Body: Default, Method: Default, Path: Default> Default for SignerBuilder<'a, Kid, Pk, Body, Method, Path>

source§

fn default() -> SignerBuilder<'a, Kid, Pk, Body, Method, Path>

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

Auto Trait Implementations§

§

impl<'a, Kid, Pk, Body, Method, Path> Freeze for SignerBuilder<'a, Kid, Pk, Body, Method, Path>
where Body: Freeze, Kid: Freeze, Method: Freeze, Path: Freeze, Pk: Freeze,

§

impl<'a, Kid, Pk, Body, Method, Path> RefUnwindSafe for SignerBuilder<'a, Kid, Pk, Body, Method, Path>
where Body: RefUnwindSafe, Kid: RefUnwindSafe, Method: RefUnwindSafe, Path: RefUnwindSafe, Pk: RefUnwindSafe,

§

impl<'a, Kid, Pk, Body, Method, Path> Send for SignerBuilder<'a, Kid, Pk, Body, Method, Path>
where Body: Send, Kid: Send, Method: Send, Path: Send, Pk: Send,

§

impl<'a, Kid, Pk, Body, Method, Path> Sync for SignerBuilder<'a, Kid, Pk, Body, Method, Path>
where Body: Sync, Kid: Sync, Method: Sync, Path: Sync, Pk: Sync,

§

impl<'a, Kid, Pk, Body, Method, Path> Unpin for SignerBuilder<'a, Kid, Pk, Body, Method, Path>
where Body: Unpin, Kid: Unpin, Method: Unpin, Path: Unpin, Pk: Unpin,

§

impl<'a, Kid, Pk, Body, Method, Path> UnwindSafe for SignerBuilder<'a, Kid, Pk, Body, Method, Path>
where Body: UnwindSafe, Kid: UnwindSafe, Method: UnwindSafe, Path: UnwindSafe, Pk: 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.