pub struct Proven<T> { /* private fields */ }
Available on crate feature
dnssec
only.Expand description
A wrapper type to ensure that the state of a DNSSEC proof is evaluated before use
Implementations§
Source§impl<T> Proven<T>
impl<T> Proven<T>
Sourcepub fn require_as_ref<I: Into<ProofFlags>>(&self, flags: I) -> Result<&T, Proof>
pub fn require_as_ref<I: Into<ProofFlags>>(&self, flags: I) -> Result<&T, Proof>
Attempts to borrow the value only if it matches flags, returning the associated proof on failure
use hickory_proto::dnssec::{Proof, Proven};
let proven = Proven::new(Proof::Bogus, 42u32);
assert_eq!(*proven.require_as_ref(Proof::Bogus).unwrap(), 42_u32);
assert_eq!(*proven.require_as_ref(Proof::Bogus | Proof::Indeterminate).unwrap(), 42_u32);
assert_eq!(proven.require_as_ref(Proof::Secure | Proof::Insecure).unwrap_err(), Proof::Bogus);
Sourcepub fn require<I: Into<ProofFlags>>(self, flags: I) -> Result<T, Self>
pub fn require<I: Into<ProofFlags>>(self, flags: I) -> Result<T, Self>
Attempts to take the value only if it matches flags, returning the associated proof on failure
use hickory_proto::dnssec::{Proof, Proven};
let proven = Proven::new(Proof::Bogus, 42u32);
assert_eq!(proven.clone().require(Proof::Bogus).unwrap(), 42_u32);
assert_eq!(proven.clone().require(Proof::Bogus | Proof::Indeterminate).unwrap(), 42_u32);
assert!(proven.require(Proof::Secure | Proof::Insecure).is_err());
Sourcepub fn map<U, F>(self, f: F) -> Proven<U>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> Proven<U>where
F: FnOnce(T) -> U,
Map the value with the associated function, carrying forward the proof
Sourcepub fn into_parts(self) -> (Proof, T)
pub fn into_parts(self) -> (Proof, T)
Unwraps the Proven type into it’s parts
Trait Implementations§
impl<T: Eq> Eq for Proven<T>
impl<T> StructuralPartialEq for Proven<T>
Auto Trait Implementations§
impl<T> Freeze for Proven<T>where
T: Freeze,
impl<T> RefUnwindSafe for Proven<T>where
T: RefUnwindSafe,
impl<T> Send for Proven<T>where
T: Send,
impl<T> Sync for Proven<T>where
T: Sync,
impl<T> Unpin for Proven<T>where
T: Unpin,
impl<T> UnwindSafe for Proven<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.