Implement DigestVerify for Vec, &mut []

This commit is contained in:
asonix 2020-01-17 16:56:22 -06:00
parent 77ecf6eaa7
commit a2bc8c03ee

View file

@ -87,6 +87,24 @@ fn parse_digest_header() -> impl Filter<Extract = (Vec<DigestPart>,), Error = Re
header::header::<Digest>("Digest").map(|d: Digest| d.parts)
}
impl<T> DigestVerify for Vec<T>
where
T: DigestVerify,
{
fn verify(&mut self, parts: &[DigestPart], payload: &[u8]) -> bool {
self.iter_mut().any(|d| d.verify(parts, payload))
}
}
impl<T> DigestVerify for &mut [T]
where
T: DigestVerify,
{
fn verify(&mut self, parts: &[DigestPart], payload: &[u8]) -> bool {
self.iter_mut().any(|d| d.verify(parts, payload))
}
}
impl FromStr for DigestPart {
type Err = ParseDigestError;