pub struct Restrict<T>(_);
Untrusted types will be wrapped in this type.
To gain access to the data, some form of verification through one of the public methods is necessary.
Create a new restricted type
It is the responsibility of th function to verfy the contained type is valid.
use trust_dns_proto::serialize::binary::Restrict;
let unrestricted = Restrict::new(0).verify(|r| *r == 0).then(|r| *r + 1).unwrap();
assert!(unrestricted == 1);
If f
returns true then the value is valid and a chainable Verified
type is returned
It is the responsibility of th function to verfy the contained type is valid.
use trust_dns_proto::serialize::binary::Restrict;
let unrestricted = Restrict::new(0).verify_unwrap(|r| *r == 0).unwrap();
assert!(unrestricted == 0);
If f
returns true then the value is valid and Ok(T)
is returned. Otherwise
Err(T)
is returned.
Unwraps the value without verifying the data, akin to Result::unwrap and Option::unwrap, but will not panic
Map the internal type of the restriction
use trust_dns_proto::serialize::binary::Restrict;
let restricted = Restrict::new(0).map(|b| vec![b, 1]);
assert!(restricted.verify(|v| v == &[0, 1]).is_valid());
assert!(!restricted.verify(|v| v == &[1, 0]).is_valid());
Argument for the math operations
Return value, generally the same as Arg
Checked addition, see usize::checked_add
Checked subtraction, see usize::checked_sub
Checked multiplication, see usize::checked_mul
Argument for the math operations
Return value, generally the same as Arg
Checked addition, see usize::checked_add
Checked subtraction, see usize::checked_sub
Checked multiplication, see usize::checked_mul
Argument for the math operations
Return value, generally the same as Arg
Checked addition, see usize::checked_add
Checked subtraction, see usize::checked_sub
Checked multiplication, see usize::checked_mul
Performs copy-assignment from source
. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)