pub(crate) fn new(digest: &Digest) -> Option<Validator> {
        const EXPECT_VALID: &str = "digest struct should never be backed by a malformed string";

        let mut parts = digest.as_str().split(':');
        let algorithm = parts
            .next()
            .expect(EXPECT_VALID)
            .parse::<AlgorithmKind>()
            .expect(EXPECT_VALID);
        let digest_str = parts.next().expect(EXPECT_VALID);

        use AlgorithmKind::*;

        Some(Validator {
            expect_digest: match algorithm {
                Sha256 | Sha384 | Sha512 => hex::decode(digest_str).expect(EXPECT_VALID),
                Unregistered(_) => return None,
            },
            digest: match algorithm {
                Sha256 => Box::new(sha2::Sha256::default()),
                Sha384 => Box::new(sha2::Sha384::default()),
                Sha512 => Box::new(sha2::Sha512::default()),
                Unregistered(_) => return None,
            },
        })
    }
/// Returns a new Validator.
/// If the digest algorithm is not recognized, returns None instead.
Returns a new Validator.
If the digest algorithm is not recognized, returns None instead.
Returns a new Validator . If the digest algorithm is not recognized returns None instead .
pub(crate) fn new(digest: &Digest) -> Option<Validator> {
        const EXPECT_VALID: &str = "digest struct should never be backed by a malformed string";
        let mut parts = digest.as_str().split(':');
        let algorithm = parts
            .next()
            .expect(EXPECT_VALID)
            .parse::<AlgorithmKind>()
            .expect(EXPECT_VALID);
        let digest_str = parts.next().expect(EXPECT_VALID);
        use AlgorithmKind::*;
        Some(Validator {
            expect_digest: match algorithm {
                Sha256 | Sha384 | Sha512 => hex::decode(digest_str).expect(EXPECT_VALID),
                Unregistered(_) => return None,
            },
            digest: match algorithm {
                Sha256 => Box::new(sha2::Sha256::default()),
                Sha384 => Box::new(sha2::Sha384::default()),
                Sha512 => Box::new(sha2::Sha512::default()),
                Unregistered(_) => return None,
            },
        })
    }
pub ( crate ) fn new ( digest : & Digest ) -> Option < Validator > { const EXPECT_VALID : & str = " " ; let mut parts = digest . as_str ( ) . split ( ':' ) ; let algorithm = parts . next ( ) . expect ( EXPECT_VALID ) . parse :: < AlgorithmKind > ( ) . expect ( EXPECT_VALID ) ; let digest_str = parts . next ( ) . expect ( EXPECT_VALID ) ; use AlgorithmKind :: * ; Some ( Validator { expect_digest : match algorithm { Sha256 | Sha384 | Sha512 => hex :: decode ( digest_str ) . expect ( EXPECT_VALID ) , Unregistered ( _ ) => return None , } , digest : match algorithm { Sha256 => Box :: new ( sha2 :: Sha256 :: default ( ) ) , Sha384 => Box :: new ( sha2 :: Sha384 :: default ( ) ) , Sha512 => Box :: new ( sha2 :: Sha512 :: default ( ) ) , Unregistered ( _ ) => return None , } , } ) }
Returns a new Validator.
Returns a new Validator .
digest
&Digest
digest
&Digest