Struct hickory_proto::rr::dnssec::proof::Proven

source ·
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>

source

pub fn new(proof: Proof, value: T) -> Self

Wrap the value with the given proof

source

pub fn proof(&self) -> Proof

Get the associated proof

source

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::rr::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);
source

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::rr::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());
source

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

source

pub fn into_parts(self) -> (Proof, T)

Unwraps the Proven type into it’s parts

source§

impl<T> Proven<Option<T>>

source

pub fn transpose(self) -> Option<Proven<T>>

If the inner type is an Option this will transpose them so that it’s an option wrapped Proven

Trait Implementations§

source§

impl<T: Clone> Clone for Proven<T>

source§

fn clone(&self) -> Proven<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Proven<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Record> for Proven<&'a Record>

source§

fn from(record: &'a Record) -> Self

Converts to this type from the input type.
source§

impl From<Record> for Proven<Record>

source§

fn from(record: Record) -> Self

Converts to this type from the input type.
source§

impl<T: PartialEq> PartialEq for Proven<T>

source§

fn eq(&self, other: &Proven<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for Proven<T>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more