Area

Struct Area 

Source
pub struct Area<const MCL: usize, const MCC: usize, const MPL: usize, S> { /* private fields */ }
Expand description

An Area is a box in three-dimensional willow space, consisting of all entries matching either a single subspace id or entries of arbitrary subspace ids, prefixed by some Path, and a TimeRange.

Areas are the default way by which application developers should aggregate entries. See the specification for more details.

use willow_data_model::prelude::*;

let a1 = Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17));

assert!(a1.wdm_includes(&(6, Path::new(), Timestamp::from(9))));
assert_eq!(a1.subspace(), None);

let a2 = Area::<2, 2, 2, u8>::new(Some(42), Path::new(), Timestamp::from(15)..);
assert_eq!(
    a1.wdm_intersection(&a2),
    Area::<2, 2, 2, u8>::new(
        Some(42),
        Path::new(),
        Timestamp::from(15)..Timestamp::from(17),
    ),
);

Specification

Implementations§

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>

Source

pub fn new<TR>( subspace: Option<S>, path: Path<MCL, MCC, MPL>, times: TR, ) -> Self
where TR: Into<TimeRange>,

Creates a new Area from its constituent optional subspace id, Path, and TimeRange.

use willow_data_model::prelude::*;

let a = Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17));

assert!(a.wdm_includes(&(6, Path::new(), Timestamp::from(9))));
assert_eq!(a.subspace(), None);
Source

pub fn subspace(&self) -> Option<&S>

Returns a reference to the inner subspace id, if any.

use willow_data_model::prelude::*;

let a1 = Area::<2, 2, 2, u8>::new(Some(17), Path::new(), ..Timestamp::from(17));
assert_eq!(a1.subspace(), Some(&17));

let a2 = Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17));
assert_eq!(a2.subspace(), None);

Definition.

Source

pub fn path(&self) -> &Path<MCL, MCC, MPL>

Returns a reference to the inner Path.

use willow_data_model::prelude::*;

let a = Area::<2, 2, 2, u8>::new(Some(17), Path::new(), ..Timestamp::from(17));
assert_eq!(a.path(), &Path::new());

Definition.

Source

pub fn times(&self) -> &TimeRange

Returns a reference to the inner TimeRange.

use willow_data_model::prelude::*;

let a = Area::<2, 2, 2, u8>::new(Some(17), Path::new(), ..Timestamp::from(17));
assert_eq!(a.times(), &WillowRange::from(..Timestamp::from(17)));

Definition.

Source

pub fn set_subspace(&mut self, new_subspace: Option<S>)

Sets the inner subspace id.

Source

pub fn set_path(&mut self, new_path: Path<MCL, MCC, MPL>)

Sets the inner Path.

Source

pub fn set_times<TR>(&mut self, new_range: TR)
where TR: Into<TimeRange>,

Sets the inner TimeRange.

Source

pub fn new_subspace(subspace_id: S) -> Self

Returns the subspace area for the given subspace id, i.e., the area which includes exactly the entries of the given subspace id.

use willow_data_model::prelude::*;

let a = Area::<2, 2, 2, u8>::new_subspace(17);

assert!(a.wdm_includes(&(17, Path::new(), Timestamp::from(9))));
assert!(!a.wdm_includes(&(18, Path::new(), Timestamp::from(9))));
assert_eq!(a.subspace(), Some(&17));
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>

Source

pub fn admits_pruning_by<Coord>(&self, coord: &Coord) -> bool
where Coord: Coordinatelike<MCL, MCC, MPL, S>,

Returns whether an Entry of the given coordinate could possibly cause prefix pruning in this area.

use willow_data_model::prelude::*;

let a = Area::<2, 2, 2, u8>::new(Some(17), Path::new(), ..Timestamp::from(17));

assert!(a.admits_pruning_by(&(17, Path::new(), Timestamp::from(9))));
assert!(!a.admits_pruning_by(&(18, Path::new(), Timestamp::from(9))));
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>

Source

pub fn full() -> Self

Returns the Area which includes every coordinate.

use willow_data_model::prelude::*;

let a = Area::<2, 2, 2, u8>::full();

assert!(a.wdm_includes(&(6, Path::new(), Timestamp::from(9))));
assert!(a.wdm_includes(&(16, Path::new(), Timestamp::from(9))));
Source

pub fn is_full(&self) -> bool

Returns whether self is the full area, i.e., the area which includes every coordinate.

use willow_data_model::prelude::*;

assert!(Area::<2, 2, 2, u8>::full().is_full());
assert!(!Area::<2, 2, 2, u8>::new(Some(17), Path::new(), ..Timestamp::from(17)).is_full());

Trait Implementations§

Source§

impl<'arbitrary, const MCL: usize, const MCC: usize, const MPL: usize, S: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for Area<MCL, MCC, MPL, S>

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Clone> Clone for Area<MCL, MCC, MPL, S>

Source§

fn clone(&self) -> Area<MCL, MCC, MPL, S>

Returns a duplicate 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<const MCL: usize, const MCC: usize, const MPL: usize, S: Debug> Debug for Area<MCL, MCC, MPL, S>

Source§

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

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

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> From<Area<MCL, MCC, MPL, S>> for Range3d<MCL, MCC, MPL, S>

Source§

fn from(value: Area<MCL, MCC, MPL, S>) -> Self

Converts to this type from the input type.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> GreatestElement for Area<MCL, MCC, MPL, S>

Source§

fn greatest() -> Self

Returns the unique greatest element. Read more
Source§

fn is_greatest(&self) -> bool

Returns true if and only if self is the greatest element.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Grouping<MCL, MCC, MPL, S> for Area<MCL, MCC, MPL, S>

Source§

fn wdm_includes<Coord>(&self, coord: &Coord) -> bool
where Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,

Returns true iff the given Coordinatelike value is included in this grouping.
Source§

fn wdm_includes_grouping(&self, other: &Self) -> bool

Returns true iff every value included in other is also included in self.
Source§

fn wdm_strictly_includes_grouping(&self, other: &Self) -> bool

Returns true iff every value included in other is also included in self and self and other are not equal.
Source§

fn wdm_includes_in_intersection<Coord>( &self, other: &Self, coord: &Coord, ) -> bool
where Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,

Returns true iff the given Coordinatelike value is included in the intersection of self and other.
Source§

fn wdm_is_empty(&self) -> bool

Returns true iff self includes no values.
Source§

fn wdm_empty() -> Self

Returns a grouping which includes no values.
Source§

fn wdm_intersection(&self, other: &Self) -> Self

Returns a grouping which includes exactly those values included by both self and other.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Hash for Area<MCL, MCC, MPL, S>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LeastElement for Area<MCL, MCC, MPL, S>

Source§

fn least() -> Self

Returns the unique least element. Read more
Source§

fn is_least(&self) -> bool

Returns true if and only if self is the least element.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LowerSemilattice for Area<MCL, MCC, MPL, S>

Source§

fn greatest_lower_bound(&self, other: &Self) -> Self

Returns the greatest lower bound of self and other, i.e., the unique greatest element in the type which is less than or equal to both self and other.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> PartialEq for Area<MCL, MCC, MPL, S>

An area is equal to another iff both include exactly the same values.

This implementation assumes that S is inhabited by more than one value.

Source§

fn eq(&self, other: &Self) -> 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<const MCL: usize, const MCC: usize, const MPL: usize, S> PartialOrd for Area<MCL, MCC, MPL, S>

An area is less than another iff all values included in the first are also included in the other.

This implementation assumes that S is inhabited by more than one value.

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

An area is less than another iff all values included in the first are also included in the other.

This implementation assumes that S is inhabited by more than one value.

1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> UpperSemilattice for Area<MCL, MCC, MPL, S>

Source§

fn least_upper_bound(&self, other: &Self) -> Self

Returns the least upper bound of self and other, i.e., the unique least element in the type which is greater than or equal to both self and other.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Eq for Area<MCL, MCC, MPL, S>

Auto Trait Implementations§

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> !Freeze for Area<MCL, MCC, MPL, S>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RefUnwindSafe for Area<MCL, MCC, MPL, S>
where S: RefUnwindSafe,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Send for Area<MCL, MCC, MPL, S>
where S: Send,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Sync for Area<MCL, MCC, MPL, S>
where S: Sync,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Unpin for Area<MCL, MCC, MPL, S>
where S: Unpin,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> UnwindSafe for Area<MCL, MCC, MPL, S>
where S: 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> BoundedLowerSemilattice for T

Source§

fn greatest_lower_bound_slice(values: &[Self]) -> Self

Computes the greatest lower bound of all values in the slice. For the empty slice, this is the least element.
Source§

impl<T> BoundedUpperSemilattice for T

Source§

fn least_upper_bound_slice(values: &[Self]) -> Self

Computes the least upper bound of all values in the slice. For the empty slice, this is the greatest element.
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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,

Source§

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

Source§

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

Source§

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> BoundedLattice for T

Source§

impl<T> Lattice for T