Struct opendp::domains::VectorDomain
source · pub struct VectorDomain<D: Domain> {
pub element_domain: D,
pub size: Option<usize>,
}
Expand description
A Domain that contains vectors of (homogeneous) values.
Proof Definition
VectorDomain(inner_domain, D, Option<size>)
is the domain of all vectors of elements drawn from domain inner_domain
.
If size is specified, then the domain is further restricted to all vectors of the given size.
Example
use opendp::domains::{VectorDomain, AtomDomain};
use opendp::core::Domain;
// Represents the domain of vectors.
let vec_domain = VectorDomain::new(AtomDomain::default());
assert!(vec_domain.member(&vec![1, 2, 3])?);
// Represents the domain of all vectors of bounded elements.
let bounded_domain = VectorDomain::new(AtomDomain::new_closed((-10, 10))?);
// vec![0] is a member, but vec![12] is not, because 12 is out of bounds of the inner domain
assert!(bounded_domain.member(&vec![0])?);
assert!(!bounded_domain.member(&vec![12])?);
Size Example
use opendp::domains::{VectorDomain, AtomDomain};
// Create a domain that includes all i32 vectors of length 3.
let sized_domain = VectorDomain::new(AtomDomain::<i32>::default()).with_size(3);
// vec![1, 2, 3] is a member of the sized_domain
use opendp::core::Domain;
assert!(sized_domain.member(&vec![1, 2, 3])?);
// vec![1, 2] is not a member of the sized_domain
assert!(!sized_domain.member(&vec![1, 2])?);
Fields§
§element_domain: D
§size: Option<usize>
Implementations§
Trait Implementations§
source§impl<D: Clone + Domain> Clone for VectorDomain<D>
impl<D: Clone + Domain> Clone for VectorDomain<D>
source§fn clone(&self) -> VectorDomain<D>
fn clone(&self) -> VectorDomain<D>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<D: Domain> Debug for VectorDomain<D>
impl<D: Domain> Debug for VectorDomain<D>
source§impl<D: Domain> Domain for VectorDomain<D>
impl<D: Domain> Domain for VectorDomain<D>
source§impl<D: Domain> IsSizedDomain for VectorDomain<D>
impl<D: Domain> IsSizedDomain for VectorDomain<D>
source§impl<D: LipschitzMulFloatDomain> LipschitzMulFloatDomain for VectorDomain<D>where
D::Atom: Copy + SaturatingMul + CheckNull + TotalOrd,
impl<D: LipschitzMulFloatDomain> LipschitzMulFloatDomain for VectorDomain<D>where D::Atom: Copy + SaturatingMul + CheckNull + TotalOrd,
source§impl<D: PartialEq + Domain> PartialEq<VectorDomain<D>> for VectorDomain<D>
impl<D: PartialEq + Domain> PartialEq<VectorDomain<D>> for VectorDomain<D>
source§fn eq(&self, other: &VectorDomain<D>) -> bool
fn eq(&self, other: &VectorDomain<D>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<D: Domain> StructuralPartialEq for VectorDomain<D>
Auto Trait Implementations§
impl<D> RefUnwindSafe for VectorDomain<D>where D: RefUnwindSafe,
impl<D> Send for VectorDomain<D>where D: Send,
impl<D> Sync for VectorDomain<D>where D: Sync,
impl<D> Unpin for VectorDomain<D>where D: Unpin,
impl<D> UnwindSafe for VectorDomain<D>where D: 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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.