pub fn encode(&self, secret: &Secret) -> Result<Self, Error> {
        match *self {
            Compact::Decoded {
                ref header,
                ref payload,
            } => {
                let mut compact = crate::Compact::with_capacity(3);
                compact.push(header)?;
                compact.push(payload)?;
                let encoded_payload = compact.encode();
                let signature = header
                    .registered
                    .algorithm
                    .sign(encoded_payload.as_bytes(), secret)?;
                compact.push(&signature)?;
                Ok(Compact::Encoded(compact))
            }
            Compact::Encoded(_) => Err(Error::UnsupportedOperation),
        }
    }
/// Encode the JWT passed and sign the payload using the algorithm from the header and the secret
/// The secret is dependent on the signing algorithm
Encode the JWT passed and sign the payload using the algorithm from the header and the secret
The secret is dependent on the signing algorithm
Encode the JWT passed and sign the payload using the algorithm from the header and the secret The secret is dependent on the signing algorithm
pub fn encode(&self, secret: &Secret) -> Result<Self, Error> {
        match *self {
            Compact::Decoded {
                ref header,
                ref payload,
            } => {
                let mut compact = crate::Compact::with_capacity(3);
                compact.push(header)?;
                compact.push(payload)?;
                let encoded_payload = compact.encode();
                let signature = header
                    .registered
                    .algorithm
                    .sign(encoded_payload.as_bytes(), secret)?;
                compact.push(&signature)?;
                Ok(Compact::Encoded(compact))
            }
            Compact::Encoded(_) => Err(Error::UnsupportedOperation),
        }
    }
pub fn encode ( & self , secret : & Secret ) -> Result < Self , Error > { match * self { Compact :: Decoded { ref header , ref payload , } => { let mut compact = crate :: Compact :: with_capacity ( 3 ) ; compact . push ( header ) ? ; compact . push ( payload ) ? ; let encoded_payload = compact . encode ( ) ; let signature = header . registered . algorithm . sign ( encoded_payload . as_bytes ( ) , secret ) ? ; compact . push ( & signature ) ? ; Ok ( Compact :: Encoded ( compact ) ) } Compact :: Encoded ( _ ) => Err ( Error :: UnsupportedOperation ) , } }
Encode the JWT passed and sign the payload using the algorithm from the header and the secret
The secret is dependent on the signing algorithm
Encode the JWT passed and sign the payload using the algorithm from the header and the secret The secret is dependent on the signing algorithm
&self
secret
&Secret
&self
secret
&Secret