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(), TimeRange::new_closed(0.into(), 17.into()));
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(), TimeRange::new_open(15.into()));
assert_eq!(
a1.wdm_intersection(&a2),
Ok(Area::<2, 2, 2, u8>::new(
Some(42),
Path::new(),
TimeRange::new_closed(15.into(), 17.into()),
)),
);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 new(
subspace: Option<S>,
path: Path<MCL, MCC, MPL>,
times: TimeRange,
) -> Self
pub fn new( subspace: Option<S>, path: Path<MCL, MCC, MPL>, times: TimeRange, ) -> Self
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(), TimeRange::new_closed(0.into(), 17.into()));
assert!(a.wdm_includes(&(6, Path::new(), Timestamp::from(9))));
assert_eq!(a.subspace(), None);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(), TimeRange::new_closed(0.into(), 17.into()));
assert_eq!(a1.subspace(), Some(&17));
let a2 = Area::<2, 2, 2, u8>::new(None, Path::new(), TimeRange::new_closed(0.into(), 17.into()));
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(), TimeRange::new_closed(0.into(), 17.into()));
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(), TimeRange::new_closed(0.into(), 17.into()));
assert_eq!(a.times(), &WillowRange::from(TimeRange::new_closed(0.into(), 17.into())));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_area(subspace_id: S) -> Self
pub fn new_subspace_area(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_area(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));Sourcepub fn as_ref_subspace(&self) -> Area<MCL, MCC, MPL, &S>
pub fn as_ref_subspace(&self) -> Area<MCL, MCC, MPL, &S>
Turns an &Area<MCL, MCC, MPL, S> into an Area<MCL, MCC, MPL, &S>.
Works by using Option::as_ref on the subspace and cloning everything else.
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>where
S: PartialEq,
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Area<MCL, MCC, MPL, S>where
S: PartialEq,
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(), TimeRange::new_closed(0.into(), 17.into()));
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(), TimeRange::new_closed(0.into(), 17.into())).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>where
S: PartialOrd,
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> GreatestElement for Area<MCL, MCC, MPL, S>where
S: PartialOrd,
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Grouping<MCL, MCC, MPL, S> for Area<MCL, MCC, MPL, S>where
S: PartialEq,
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Grouping<MCL, MCC, MPL, S> for Area<MCL, MCC, MPL, S>where
S: PartialEq,
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_intersection(&self, other: &Self) -> Result<Self, EmptyGrouping>where
S: Clone,
fn wdm_intersection(&self, other: &Self) -> Result<Self, EmptyGrouping>where
S: Clone,
self and other. If that set would be empty, returns an EmptyGrouping error instead.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§impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Hash> Hash for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Hash> Hash for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S: PartialEq> PartialEq for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S: PartialEq> PartialEq for Area<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> PartialOrd for Area<MCL, MCC, MPL, S>where
S: PartialEq,
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>where
S: PartialEq,
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> RelativeDecodable<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>
Implements EncodeAreaInArea.
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeDecodable<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>
Implements EncodeAreaInArea.
Source§type ErrorReason = Blame
type ErrorReason = Blame
Source§async fn relative_decode<P>(
rel: &Area<MCL, MCC, MPL, S>,
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
async fn relative_decode<P>( rel: &Area<MCL, MCC, MPL, S>, producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
rel into a Self, or yields an error if the producer does not produce a valid relative encoding. Read moreSource§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeDecodableCanonic<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>
Implements encode_area_in_area.
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeDecodableCanonic<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>
Implements encode_area_in_area.
Source§type ErrorCanonic = Blame
type ErrorCanonic = Blame
Self. Read moreSource§async fn relative_decode_canonic<P>(
rel: &Area<MCL, MCC, MPL, S>,
producer: &mut P,
) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
async fn relative_decode_canonic<P>( rel: &Area<MCL, MCC, MPL, S>, producer: &mut P, ) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
rel into a Self, and errors if the input encoding is not the canonical one.Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeEncodable<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>
Implements encode_area_in_area.
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeEncodable<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>
Implements encode_area_in_area.
Source§fn can_be_encoded_relative_to(&self, rel: &Area<MCL, MCC, MPL, S>) -> bool
fn can_be_encoded_relative_to(&self, rel: &Area<MCL, MCC, MPL, S>) -> bool
Returns true iff rel includes self.
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeEncodableKnownLength<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>where
S: PartialEq + EncodableKnownLength,
Implements encode_area_in_area.
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> RelativeEncodableKnownLength<Area<MCL, MCC, MPL, S>> for Area<MCL, MCC, MPL, S>where
S: PartialEq + EncodableKnownLength,
Implements encode_area_in_area.
Source§fn len_of_relative_encoding(&self, rel: &Area<MCL, MCC, MPL, S>) -> usize
fn len_of_relative_encoding(&self, rel: &Area<MCL, MCC, MPL, S>) -> usize
self, relative to rel. A successful call to relative_encode must feed exactly that many symbols into the bulk consumer. Read moreimpl<const MCL: usize, const MCC: usize, const MPL: usize, S: Eq> Eq for Area<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> StructuralPartialEq 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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more