Struct opendp::domains::AtomDomain

source ·
pub struct AtomDomain<T: CheckAtom> {
    bounds: Option<Bounds<T>>,
    nullable: bool,
}
Expand description

Proof Definition

AtomDomain(T) is the domain of all values of an atomic type T. If bounds are set, then the domain is restricted to the bounds. If nullable is set, then null value(s) are included in the domain.

Notes

If nullable is set, a domain may have multiple possible null values, like in the case of floating-point numbers, which have ~2^MANTISSA_BITS null values.

Because domains are defined in terms of a union, null values need a conceptual definition of equality to uniquely identify them in a set. In order to construct a well-defined set of members in the domain, we consider null values to have the same identity if their bit representation is equal.

Example

// Create a domain that includes all values `{0, 1, ..., 2^32 - 1}`.
use opendp::domains::AtomDomain;
let i32_domain = AtomDomain::<i32>::default();

// 1 is a member of the i32_domain
use opendp::core::Domain;
assert!(i32_domain.member(&1)?);

// Create a domain that includes all non-null 32-bit floats.
let f32_domain = AtomDomain::<f32>::default();

// 1. is a member of the f32_domain
assert!(f32_domain.member(&1.)?);
// NAN is not a member of the f32_domain
assert!(!f32_domain.member(&f32::NAN)?);

Null Example

use opendp::domains::{Null, AtomDomain};
let all_domain = AtomDomain::default();
let null_domain = AtomDomain::new_nullable();

use opendp::core::Domain;
// f64 NAN is not a member of all_domain, but is a member of null_domain
assert!(!all_domain.member(&f64::NAN)?);
assert!(null_domain.member(&f64::NAN)?);

Fields§

§bounds: Option<Bounds<T>>§nullable: bool

Implementations§

source§

impl<T: CheckAtom> AtomDomain<T>

source

pub fn new(bounds: Option<Bounds<T>>, nullable: Option<Null<T>>) -> Self

source

pub fn nullable(&self) -> bool

source§

impl<T: CheckAtom + InherentNull> AtomDomain<T>

source

pub fn new_nullable() -> Self

source§

impl<T: CheckAtom + TotalOrd> AtomDomain<T>

source

pub fn new_closed(bounds: (T, T)) -> Fallible<Self>

Trait Implementations§

source§

impl<T: Clone + CheckAtom> Clone for AtomDomain<T>

source§

fn clone(&self) -> AtomDomain<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: CheckAtom> Debug for AtomDomain<T>

source§

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

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

impl<T: CheckAtom> Default for AtomDomain<T>

source§

fn default() -> Self

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

impl<T: CheckAtom> Domain for AtomDomain<T>

§

type Carrier = T

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<T: CheckAtom + InherentNull + Clone> DropNullDomain for AtomDomain<T>

how to standardize into an option, when null represented as T with internal nullity

§

type Imputed = T

This is the type of Self::Carrier after dropping null. Read more
source§

fn option(value: &Self::Carrier) -> Option<T>

Standardizes D::Carrier into an Option<D::Imputed>, where D::Imputed is never null. Read more
source§

impl<T: CheckAtom + InherentNull> ImputeConstantDomain for AtomDomain<T>

§

type Imputed = <AtomDomain<T> as Domain>::Carrier

This is the type of Self::Carrier after imputation. Read more
source§

fn impute_constant<'a>( default: &'a Self::Carrier, constant: &'a Self::Imputed ) -> &'a Self::Imputed

A function that replaces a potentially-null carrier type with a non-null imputed type. Read more
source§

impl<T> LipschitzMulFloatDomain for AtomDomain<T>where T: 'static + Float,

§

type Atom = T

source§

fn transform(constant: &T, (lower, upper): &(T, T), v: &T) -> Fallible<T>

source§

impl<T: PartialEq + CheckAtom> PartialEq<AtomDomain<T>> for AtomDomain<T>

source§

fn eq(&self, other: &AtomDomain<T>) -> 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<T: CheckAtom> StructuralPartialEq for AtomDomain<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for AtomDomain<T>where T: RefUnwindSafe,

§

impl<T> Send for AtomDomain<T>where T: Send,

§

impl<T> Sync for AtomDomain<T>where T: Sync,

§

impl<T> Unpin for AtomDomain<T>where T: Unpin,

§

impl<T> UnwindSafe for AtomDomain<T>where T: 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.