propaga_core/domain.rs
1/// Read-only interface for inspecting a variable domain.
2pub trait DomainView {
3 /// Value type stored in the domain.
4 type Value: Copy + Eq + Ord + std::fmt::Debug;
5
6 /// Returns `true` when the domain contains no values.
7 fn is_empty(&self) -> bool;
8
9 /// Returns `true` when the domain contains exactly one value.
10 fn is_fixed(&self) -> bool;
11
12 /// Returns the number of values in the domain.
13 fn size(&self) -> usize;
14
15 /// Returns the smallest value in the domain, if any.
16 fn min(&self) -> Option<Self::Value>;
17
18 /// Returns the largest value in the domain, if any.
19 fn max(&self) -> Option<Self::Value>;
20
21 /// Returns `true` when the domain contains `value`.
22 fn contains(&self, value: Self::Value) -> bool;
23}
24
25/// Domain that can be cloned and stored in the engine.
26pub trait Domain: DomainView + Clone {}