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),
),
);Implementations§
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>
Sourcepub fn subspace(&self) -> Option<&S>
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);Sourcepub fn path(&self) -> &Path<MCL, MCC, MPL>
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());Sourcepub fn times(&self) -> &TimeRange
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)));Sourcepub fn set_subspace(&mut self, new_subspace: Option<S>)
pub fn set_subspace(&mut self, new_subspace: Option<S>)
Sets the inner subspace id.
Sourcepub fn new_subspace(subspace_id: S) -> Self
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>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>
Sourcepub fn admits_pruning_by<Coord>(&self, coord: &Coord) -> boolwhere
Coord: Coordinatelike<MCL, MCC, MPL, S>,
pub fn admits_pruning_by<Coord>(&self, coord: &Coord) -> boolwhere
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>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>
Sourcepub fn full() -> Self
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))));Sourcepub fn is_full(&self) -> bool
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>
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>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Clone> Clone for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Clone> Clone for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Debug> Debug for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Debug> Debug for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> From<Area<MCL, MCC, MPL, S>> for Range3d<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> From<Area<MCL, MCC, MPL, S>> for Range3d<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> GreatestElement for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> GreatestElement for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Grouping<MCL, MCC, MPL, S> for Area<MCL, MCC, MPL, S>
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) -> boolwhere
Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,
fn wdm_includes<Coord>(&self, coord: &Coord) -> boolwhere
Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,
true iff the given Coordinatelike value is included in this grouping.Source§fn wdm_includes_grouping(&self, other: &Self) -> bool
fn wdm_includes_grouping(&self, other: &Self) -> bool
Source§fn wdm_strictly_includes_grouping(&self, other: &Self) -> bool
fn wdm_strictly_includes_grouping(&self, other: &Self) -> bool
Source§fn wdm_includes_in_intersection<Coord>(
&self,
other: &Self,
coord: &Coord,
) -> boolwhere
Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,
fn wdm_includes_in_intersection<Coord>(
&self,
other: &Self,
coord: &Coord,
) -> boolwhere
Coord: Coordinatelike<MCL, MCC, MPL, S> + ?Sized,
Source§fn wdm_is_empty(&self) -> bool
fn wdm_is_empty(&self) -> bool
Source§fn wdm_intersection(&self, other: &Self) -> Self
fn wdm_intersection(&self, other: &Self) -> Self
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Hash for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Hash for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LeastElement for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LeastElement for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LowerSemilattice for Area<MCL, MCC, MPL, S>
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
fn greatest_lower_bound(&self, other: &Self) -> Self
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.
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§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.
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>
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.
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> UpperSemilattice for Area<MCL, MCC, MPL, S>
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
fn least_upper_bound(&self, other: &Self) -> Self
self and other, i.e., the unique least element in the type which is greater than or equal to both self and other.