AreaOfInterest

Struct AreaOfInterest 

Source
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(), TimeRange::new_closed(0.into(), 17.into())),
    NonZeroU64::new(5).unwrap(),
    400,
);

assert_eq!(aoi.area(), &Area::<2, 2, 2, u8>::new(None, Path::new(), TimeRange::new_closed(0.into(), 17.into())));
assert_eq!(aoi.max_count(), NonZeroU64::new(5).unwrap());
assert_eq!(aoi.max_size(), 400);

Specification

Implementations§

Source§

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

Source

pub fn new( area: Area<MCL, MCC, MPL, S>, max_count: NonZeroU64, 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(), TimeRange::new_closed(0.into(), 17.into())),
    NonZeroU64::new(5).unwrap(),
    400,
);

assert_eq!(
    aoi.area(),
    &Area::<2, 2, 2, u8>::new(None, Path::new(), TimeRange::new_closed(0.into(), 17.into())),
);
assert_eq!(aoi.max_count(), NonZeroU64::new(5).unwrap());
assert_eq!(aoi.max_size(), 400);
Source

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(), TimeRange::new_closed(0.into(), 17.into())),
    NonZeroU64::new(5).unwrap(),
    400,
);
assert_eq!(aoi.area(), &Area::<2, 2, 2, u8>::new(None, Path::new(), TimeRange::new_closed(0.into(), 17.into())));

Definition.

Source

pub fn max_count(&self) -> NonZeroU64

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(), TimeRange::new_closed(0.into(), 17.into())),
    NonZeroU64::new(5).unwrap(),
    400,
);
assert_eq!(aoi.max_count(), NonZeroU64::new(5).unwrap());

Definition.

Source

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(), TimeRange::new_closed(0.into(), 17.into())),
    NonZeroU64::new(5).unwrap(),
    400,
);
assert_eq!(aoi.max_size(), 400);

Definition.

Source

pub fn set_area(&mut self, new_area: Area<MCL, MCC, MPL, S>)

Sets the inner area.

Source

pub fn set_max_count(&mut self, new_max_count: NonZeroU64)

Sets the max_count.

A max_count of u64::MAX indicates that there is no limit on the number of entries in this area of interest.

Source

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>
where S: PartialEq + Clone,

Source

pub fn intersection(&self, other: &Self) -> Result<Self, EmptyGrouping>

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(), TimeRange::new_closed(0.into(), 17.into())),
    NonZeroU64::new(5).unwrap(),
    400,
);
let aoi2 = AreaOfInterest::new(
    Area::<2, 2, 2, u8>::new(None, Path::new(), TimeRange::new_open(14.into())),
    NonZeroU64::new(12).unwrap(),
    32,
);

assert_eq!(
    aoi1.intersection(&aoi2),
    Ok(AreaOfInterest::new(
        Area::<2, 2, 2, u8>::new(
            None,
            Path::new(),
            TimeRange::new_closed(14.into(), 17.into()),
        ),
        NonZeroU64::new(5).unwrap(),
        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>

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 AreaOfInterest<MCL, MCC, MPL, S>

Source§

fn clone(&self) -> AreaOfInterest<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 AreaOfInterest<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> GreatestElement for AreaOfInterest<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: Hash> Hash for AreaOfInterest<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: PartialEq> PartialEq for AreaOfInterest<MCL, MCC, MPL, S>

Source§

fn eq(&self, other: &AreaOfInterest<MCL, MCC, MPL, S>) -> 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 AreaOfInterest<MCL, MCC, MPL, S>

An area is less than another iff is is empty but the other is not, or if its area is less than the other’s area and its max_count and max_size are not strictly greater than those of 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 it has a max_count of zero (and the other doesn’t), or if its area is less than the other’s area and its max_count and max_size are not strictly greater than those of 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: Eq> Eq for AreaOfInterest<MCL, MCC, MPL, S>

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S> StructuralPartialEq for AreaOfInterest<MCL, MCC, MPL, S>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.