Struct rjwt::Actor[][src]

pub struct Actor<A> { /* fields omitted */ }

An actor with an identifier of type T and an ECDSA keypair used to sign tokens.

IMPORTANT NOTE: for security reasons, although Actor implements Clone, its secret key will NOT be cloned. For example:

let actor = Actor::<String>::new("id".to_string()); // this has a new secret key
let cloned = actor.clone(); // this does NOT have a secret key, only a public key

Implementations

impl<A> Actor<A>[src]

pub fn new_keypair() -> Keypair[src]

Generate a new ECDSA keypair.

pub fn new(id: A) -> Self[src]

Return an Actor with a newly-generated keypair.

pub fn with_keypair(id: A, public_key: &[u8], secret: &[u8]) -> Result<Self>[src]

Return an Actor with the given keypair, or an error if the keypair is invalid.

pub fn with_public_key(id: A, public_key: &[u8]) -> Result<Self>[src]

Return an Actor with the given public key, or an error if the key is invalid.

pub fn id(&self) -> &A[src]

The identifier of this actor.

pub fn public_key(&self) -> &PublicKey[src]

The public key of this actor, which a client can use to verify a signature.

pub fn sign_token<H: Serialize, C: Serialize>(
    &self,
    token: &Token<H, A, C>
) -> Result<String> where
    A: Serialize
[src]

Encode and sign the given token.

Trait Implementations

impl<A: Clone> Clone for Actor<A>[src]

Auto Trait Implementations

impl<A> RefUnwindSafe for Actor<A> where
    A: RefUnwindSafe
[src]

impl<A> Send for Actor<A> where
    A: Send
[src]

impl<A> Sync for Actor<A> where
    A: Sync
[src]

impl<A> Unpin for Actor<A> where
    A: Unpin
[src]

impl<A> UnwindSafe for Actor<A> where
    A: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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