pub fn encode_with_signer(
        &self,
        payload: &JwtPayload,
        header: &JwsHeader,
        signer: &dyn JwsSigner,
    ) -> Result<String, JoseError> {
        (|| -> anyhow::Result<String> {
            if let Some(vals) = header.critical() {
                if vals.contains(&"b64") {
                    bail!("JWT is not support b64 header claim.");
                }
            }

            let payload_bytes = serde_json::to_vec(payload.claims_set()).unwrap();
            let jwt = self
                .jws_context
                .serialize_compact(&payload_bytes, header, signer)?;
            Ok(jwt)
        })()
        .map_err(|err| match err.downcast::<JoseError>() {
            Ok(err) => err,
            Err(err) => JoseError::InvalidJwtFormat(err),
        })
    }
/// Return the string repsentation of the JWT with the siginig algorithm.
///
/// # Arguments
///
/// * `payload` - The payload data.
/// * `header` - The JWS heaser claims.
/// * `signer` - a signer object.
Return the string repsentation of the JWT with the siginig algorithm.
Return the string repsentation of the JWT with the siginig algorithm .
pub fn encode_with_signer(
        &self,
        payload: &JwtPayload,
        header: &JwsHeader,
        signer: &dyn JwsSigner,
    ) -> Result<String, JoseError> {
        (|| -> anyhow::Result<String> {
            if let Some(vals) = header.critical() {
                if vals.contains(&"b64") {
                    bail!("JWT is not support b64 header claim.");
                }
            }
            let payload_bytes = serde_json::to_vec(payload.claims_set()).unwrap();
            let jwt = self
                .jws_context
                .serialize_compact(&payload_bytes, header, signer)?;
            Ok(jwt)
        })()
        .map_err(|err| match err.downcast::<JoseError>() {
            Ok(err) => err,
            Err(err) => JoseError::InvalidJwtFormat(err),
        })
    }
pub fn encode_with_signer ( & self , payload : & JwtPayload , header : & JwsHeader , signer : & dyn JwsSigner , ) -> Result < String , JoseError > { ( | | -> anyhow :: Result < String > { if let Some ( vals ) = header . critical ( ) { if vals . contains ( & " " ) { bail ! ( " " ) ; } } let payload_bytes = serde_json :: to_vec ( payload . claims_set ( ) ) . unwrap ( ) ; let jwt = self . jws_context . serialize_compact ( & payload_bytes , header , signer ) ? ; Ok ( jwt ) } ) ( ) . map_err ( | err | match err . downcast :: < JoseError > ( ) { Ok ( err ) => err , Err ( err ) => JoseError :: InvalidJwtFormat ( err ) , } ) }
Return the string repsentation of the JWT with the siginig algorithm.
Return the string repsentation of the JWT with the siginig algorithm .
&self
payload
&JwtPayload
header
&JwsHeader
signer
&dyn JwsSigner
&self
payload
&JwtPayload
header
&JwsHeader
signer
&dyn JwsSigner