pub fn decode_with_decrypter_selector<'a, F>(
        &self,
        input: impl AsRef<[u8]>,
        selector: F,
    ) -> Result<(JwtPayload, JweHeader), JoseError>
    where
        F: Fn(&JweHeader) -> Result<Option<&'a dyn JweDecrypter>, JoseError>,
    {
        (|| -> anyhow::Result<(JwtPayload, JweHeader)> {
            let (payload, header) =
                self.jwe_context
                    .deserialize_compact_with_selector(input, |header| {
                        let decrypter = match selector(&header)? {
                            Some(val) => val,
                            None => return Ok(None),
                        };

                        Ok(Some(decrypter))
                    })?;

            let payload: Map<String, Value> = serde_json::from_slice(&payload)?;
            let payload = JwtPayload::from_map(payload)?;

            Ok((payload, header))
        })()
        .map_err(|err| match err.downcast::<JoseError>() {
            Ok(err) => err,
            Err(err) => JoseError::InvalidJwtFormat(err),
        })
    }
/// Return the JWT object decoded with a selected decrypting algorithm.
///
/// # Arguments
///
/// * `input` - a JWT string representation.
/// * `decrypter_selector` - a function for selecting the decrypting algorithm.
Return the JWT object decoded with a selected decrypting algorithm.
Return the JWT object decoded with a selected decrypting algorithm .
pub fn decode_with_decrypter_selector<'a, F>(
        &self,
        input: impl AsRef<[u8]>,
        selector: F,
    ) -> Result<(JwtPayload, JweHeader), JoseError>
    where
        F: Fn(&JweHeader) -> Result<Option<&'a dyn JweDecrypter>, JoseError>,
    {
        (|| -> anyhow::Result<(JwtPayload, JweHeader)> {
            let (payload, header) =
                self.jwe_context
                    .deserialize_compact_with_selector(input, |header| {
                        let decrypter = match selector(&header)? {
                            Some(val) => val,
                            None => return Ok(None),
                        };
                        Ok(Some(decrypter))
                    })?;
            let payload: Map<String, Value> = serde_json::from_slice(&payload)?;
            let payload = JwtPayload::from_map(payload)?;
            Ok((payload, header))
        })()
        .map_err(|err| match err.downcast::<JoseError>() {
            Ok(err) => err,
            Err(err) => JoseError::InvalidJwtFormat(err),
        })
    }
pub fn decode_with_decrypter_selector < ' a , F > ( & self , input : impl AsRef < [ u8 ] > , selector : F , ) -> Result < ( JwtPayload , JweHeader ) , JoseError > where F : Fn ( & JweHeader ) -> Result < Option < & ' a dyn JweDecrypter > , JoseError > , { ( | | -> anyhow :: Result < ( JwtPayload , JweHeader ) > { let ( payload , header ) = self . jwe_context . deserialize_compact_with_selector ( input , | header | { let decrypter = match selector ( & header ) ? { Some ( val ) => val , None => return Ok ( None ) , } ; Ok ( Some ( decrypter ) ) } ) ? ; let payload : Map < String , Value > = serde_json :: from_slice ( & payload ) ? ; let payload = JwtPayload :: from_map ( payload ) ? ; Ok ( ( payload , header ) ) } ) ( ) . map_err ( | err | match err . downcast :: < JoseError > ( ) { Ok ( err ) => err , Err ( err ) => JoseError :: InvalidJwtFormat ( err ) , } ) }
Return the JWT object decoded with a selected decrypting algorithm.
Return the JWT object decoded with a selected decrypting algorithm .
&self
input
impl AsRef<[u8]>
selector
F
&self
input
impl AsRef<[u8]>
selector
F