pub struct Signer { /* private fields */ }
Expand description
Used to sign outgoing requests. Struct can be initialized once and used to sign many requests.
Implementations§
Source§impl Signer
impl Signer
Sourcepub fn new(
app_uuid: impl Into<String>,
private_key_data: String,
) -> Result<Self, Error>
pub fn new( app_uuid: impl Into<String>, private_key_data: String, ) -> Result<Self, Error>
Initialize a new signer with the app UUID and the private key. The format of the private key
should be a raw RSA private key in the PKCS1 PEM format, as generated by openssl genrsa
. An
error will be returned if the input data is unable to be parsed as a private key. The app_uuid
is expected to be a valid UUID, however this is not checked. If you pass something other than
a valid UUID, no error will be returned, but none of the created signatures will be able to
be validated by other MAuth verifiers.
let signer = Signer::new("101c139a-236c-11ef-b5e3-125eb8485a60", private_key);
assert!(signer.is_ok());
Sourcepub fn sign_string(
&self,
version: u8,
verb: impl Into<String>,
path: impl Into<String>,
query: impl Into<String>,
body: &[u8],
timestamp: impl Into<String>,
) -> Result<String, Error>
pub fn sign_string( &self, version: u8, verb: impl Into<String>, path: impl Into<String>, query: impl Into<String>, body: &[u8], timestamp: impl Into<String>, ) -> Result<String, Error>
This function will generate a valid MAuth signature string of the specified version, or error if it is unable to.
let result = signer.sign_string(2, "GET", "/item", "page=2", b"", "2024-01-28T19:11:35.000");
assert!(result.is_ok());
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Signer
impl RefUnwindSafe for Signer
impl Send for Signer
impl Sync for Signer
impl Unpin for Signer
impl UnwindSafe for Signer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more