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§

source§

impl<D: Domain> VectorDomain<D>

source

pub fn new(element_domain: D) -> Self

source

pub fn with_size(self, size: usize) -> Self

source

pub fn without_size(self) -> Self

Trait Implementations§

source§

impl<D: Clone + Domain> Clone for VectorDomain<D>

source§

fn clone(&self) -> VectorDomain<D>

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<D: Domain> Debug for VectorDomain<D>

source§

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

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

impl<D: Domain + Default> Default for VectorDomain<D>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<D: Domain> Domain for VectorDomain<D>

§

type Carrier = Vec<<D as Domain>::Carrier, Global>

The underlying type that the Domain specializes. This is the type of a member of a domain, where a domain is any data type that implements this trait. Read more
source§

fn member(&self, val: &Self::Carrier) -> Fallible<bool>

Predicate to test an element for membership in the domain. Not all possible values of ::Carrier are a member of the domain. Read more
source§

impl<D: Domain> IsSizedDomain for VectorDomain<D>

source§

impl<D: LipschitzMulFloatDomain> LipschitzMulFloatDomain for VectorDomain<D>where D::Atom: Copy + SaturatingMul + CheckNull + TotalOrd,

§

type Atom = <D as LipschitzMulFloatDomain>::Atom

source§

fn transform( constant: &D::Atom, bounds: &(Self::Atom, Self::Atom), v: &Vec<D::Carrier> ) -> Fallible<Vec<D::Carrier>>

source§

impl<D: PartialEq + Domain> PartialEq<VectorDomain<D>> for VectorDomain<D>

source§

fn eq(&self, other: &VectorDomain<D>) -> bool

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

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

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

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

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>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> OverflowingAs for T

source§

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>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

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

§

fn vzip(self) -> V

source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.