pub struct AreaOfInterest<const MCL: usize, const MCC: usize, const MPL: usize, S> { /* private fields */ }Expand description
An AreaOfInterest is an Area together with a maximum number of entries it may include, and a maximum sum of total payload_lengths for the included entries.
A max_count of u64::MAX indicates that there is no limit on the number of entries. A max_size of u64::MAX indicates that there is no limit on the total payload_lengths of the entries.
use willow_data_model::prelude::*;
let aoi = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
);
assert_eq!(aoi.area(), &Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)));
assert_eq!(aoi.max_count(), 5);
assert_eq!(aoi.max_size(), 400);Implementations§
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S>
Sourcepub fn new(area: Area<MCL, MCC, MPL, S>, max_count: u64, max_size: u64) -> Self
pub fn new(area: Area<MCL, MCC, MPL, S>, max_count: u64, max_size: u64) -> Self
Creates a new AreaOfInterest from its constituent Area, max_count, and max_size.
A max_count of u64::MAX indicates that there is no limit on the number of entries. A max_size of u64::MAX indicates that there is no limit on the total payload_lengths of the entries.
use willow_data_model::prelude::*;
let aoi = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
);
assert_eq!(
aoi.area(),
&Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
);
assert_eq!(aoi.max_count(), 5);
assert_eq!(aoi.max_size(), 400);Sourcepub fn area(&self) -> &Area<MCL, MCC, MPL, S>
pub fn area(&self) -> &Area<MCL, MCC, MPL, S>
Returns a reference to the inner Area.
use willow_data_model::prelude::*;
let aoi = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
);
assert_eq!(aoi.area(), &Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)));Sourcepub fn max_count(&self) -> u64
pub fn max_count(&self) -> u64
Returns the max_count of entries.
A max_count of u64::MAX indicates that there is no limit on the number of entries in this area of interest.
use willow_data_model::prelude::*;
let aoi = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
);
assert_eq!(aoi.max_count(), 5);Sourcepub fn max_size(&self) -> u64
pub fn max_size(&self) -> u64
Returns the max_count of entries.
A max_size of u64::MAX indicates that there is no limit on the total payload_lengths of the entries in this area of interest.
use willow_data_model::prelude::*;
let aoi = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
);
assert_eq!(aoi.max_size(), 400);Sourcepub fn set_max_count(&mut self, new_max_count: u64)
pub fn set_max_count(&mut self, new_max_count: u64)
Sourcepub fn set_max_size(&mut self, new_max_size: u64)
pub fn set_max_size(&mut self, new_max_size: u64)
Sets the max_size.
A max_size of u64::MAX indicates that there is no limit on the total payload_lengths of the entries in this area of interest.
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true iff this area of interest cannot possibly contain any entries.
use willow_data_model::prelude::*;
assert!(
!AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
).is_empty(),
);
assert!(
!AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
0, // Could still possibly contain entries with a payload_length of zero.
).is_empty(),
);
assert!(
AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
0,
400,
).is_empty(),
);
assert!(
AreaOfInterest::new(
Area::<2, 2, 2, u8>::wdm_empty(),
5,
400,
).is_empty(),
);Sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
Returns the intersection of self and other.
use willow_data_model::prelude::*;
let aoi1 = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), ..Timestamp::from(17)),
5,
400,
);
let aoi2 = AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(None, Path::new(), Timestamp::from(14)..),
12,
32,
);
assert_eq!(
aoi1.intersection(&aoi2),
AreaOfInterest::new(
Area::<2, 2, 2, u8>::new(
None,
Path::new(),
Timestamp::from(14)..Timestamp::from(17),
),
5,
32,
),
);Trait Implementations§
Source§impl<'arbitrary, const MCL: usize, const MCC: usize, const MPL: usize, S: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for AreaOfInterest<MCL, MCC, MPL, S>
impl<'arbitrary, const MCL: usize, const MCC: usize, const MPL: usize, S: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for AreaOfInterest<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 AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Clone> Clone for AreaOfInterest<MCL, MCC, MPL, S>
Source§fn clone(&self) -> AreaOfInterest<MCL, MCC, MPL, S>
fn clone(&self) -> AreaOfInterest<MCL, MCC, MPL, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Debug> Debug for AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S: Debug> Debug for AreaOfInterest<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> GreatestElement for AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> GreatestElement for AreaOfInterest<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Hash for AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> Hash for AreaOfInterest<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LeastElement for AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LeastElement for AreaOfInterest<MCL, MCC, MPL, S>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LowerSemilattice for AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> LowerSemilattice for AreaOfInterest<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 AreaOfInterest<MCL, MCC, MPL, S>
An area is equal to another iff both are empty, or both have equal constituent values.
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> PartialEq for AreaOfInterest<MCL, MCC, MPL, S>
An area is equal to another iff both are empty, or both have equal constituent 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 AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> PartialOrd for AreaOfInterest<MCL, MCC, MPL, S>
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 AreaOfInterest<MCL, MCC, MPL, S>
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> UpperSemilattice for AreaOfInterest<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.