pub trait Lattice: Sized {
type Item: Clone + Eq + HashedTypeDef;
Show 39 methods
// Required methods
fn rand_lattice<R: Rng>(rng: &mut R) -> Self;
fn rand_element<R: Rng>(&self, rng: &mut R) -> SafeElement<Self::Item>;
fn ref_lattice_hash(&self) -> &u128slx;
fn contains(&self, element: &Self::Item) -> bool;
fn ref_bottom(&self) -> &SafeElement<Self::Item>;
fn ref_top(&self) -> &SafeElement<Self::Item>;
unsafe fn unsafe_meet(
&self,
element_left: &Self::Item,
element_right: &Self::Item,
) -> Self::Item;
unsafe fn unsafe_join(
&self,
element_left: &Self::Item,
element_right: &Self::Item,
) -> Self::Item;
fn from_str(&self, s: &str) -> Result<SafeElement<Self::Item>, String>;
fn to_string(
&self,
element: &SafeElement<Self::Item>,
) -> Result<String, String>;
// Provided methods
fn lattice_hash(&self) -> u128slx { ... }
fn bottom(&self) -> SafeElement<Self::Item> { ... }
fn top(&self) -> SafeElement<Self::Item> { ... }
fn is_bottom(
&self,
safe_element: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
fn is_top(
&self,
safe_element: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
unsafe fn unsafe_is_bottom(&self, element: &Self::Item) -> bool { ... }
unsafe fn unsafe_is_top(&self, element: &Self::Item) -> bool { ... }
fn meet(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<SafeElement<Self::Item>, String> { ... }
fn meet_some<'a, I>(&self, it: I) -> Result<SafeElement<Self::Item>, String>
where I: IntoIterator<Item = &'a SafeElement<Self::Item>>,
Self: 'a { ... }
fn join(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<SafeElement<Self::Item>, String> { ... }
fn join_some<'a, I>(&self, it: I) -> Result<SafeElement<Self::Item>, String>
where I: IntoIterator<Item = &'a SafeElement<Self::Item>>,
Self: 'a { ... }
fn check_safe<T>(
&self,
element: T,
) -> Result<SafeElement<Self::Item>, String>
where T: Into<Self::Item> { ... }
fn rand_elements<R: Rng, I>(
&self,
len: usize,
rng: &mut R,
) -> I::Type<SafeElement<Self::Item>>
where I: CollectionFamily1 { ... }
fn assignment(&self) -> AssignmentBuilder<Self::Item>
where Self::Item: Eq + Ord + Hash { ... }
fn assignment_with_capacity(
&self,
capacity: usize,
) -> AssignmentBuilder<Self::Item>
where Self::Item: Eq + Ord + Hash { ... }
fn prunable(
&self,
length_mid: u32,
length_max: u32,
) -> AssignmentBuilder<Self::Item>
where Self::Item: Eq + Ord + Hash { ... }
fn prunable_with_capacity(
&self,
length_mid: u32,
length_max: u32,
capacity: usize,
) -> AssignmentBuilder<Self::Item>
where Self::Item: Eq + Ord + Hash { ... }
unsafe fn unsafe_cover(&self, left: &Self::Item, right: &Self::Item) -> bool { ... }
unsafe fn unsafe_disjoint(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool { ... }
unsafe fn unsafe_implies_join(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool { ... }
unsafe fn unsafe_implied_join(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool { ... }
unsafe fn unsafe_implies_meet(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool { ... }
unsafe fn unsafe_implied_meet(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool { ... }
fn cover(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
fn disjoint(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
fn implies_join(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
fn implied_join(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
fn implies_meet(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
fn implied_meet(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String> { ... }
}Expand description
General trait for lattices
Required Associated Types§
Sourcetype Item: Clone + Eq + HashedTypeDef
type Item: Clone + Eq + HashedTypeDef
Type for encoding lattice elements:
- type
Self::Itemmay contain element which are not in the lattice - type
SafeElement<Self::Item>contains both the element and the hash of lattice in order to assert its origin:SafeElement<Self::Item>is only produced by methodcheck_safewhich control if raw element is within the latticeSafeElement<Self::Item>orSafeCollection<Self::Item,I>contains checked elements;- Safe elements are helper, but in last ressort, the user is responsible to ensure the data validity
Required Methods§
Sourcefn rand_lattice<R: Rng>(rng: &mut R) -> Self
fn rand_lattice<R: Rng>(rng: &mut R) -> Self
Random lattice generator (for tests)
rng: &mut R: random number generatorR: Rng: type of random number generator- Output: random lattice
Sourcefn rand_element<R: Rng>(&self, rng: &mut R) -> SafeElement<Self::Item>
fn rand_element<R: Rng>(&self, rng: &mut R) -> SafeElement<Self::Item>
Random element generator (for tests); elements are built safe
rng: &mut R: random number generatorR: Rng: type of random number generator- Output: random element
Sourcefn ref_lattice_hash(&self) -> &u128slx
fn ref_lattice_hash(&self) -> &u128slx
Reference to lattice hash
Sourcefn contains(&self, element: &Self::Item) -> bool
fn contains(&self, element: &Self::Item) -> bool
Test if element is from lattice
- this is necessary since type Self::Item may contain more potential elements than the lattice
element: &Self::Item: element to be tested- Output: boolean
Sourcefn ref_bottom(&self) -> &SafeElement<Self::Item>
fn ref_bottom(&self) -> &SafeElement<Self::Item>
Reference to least element of the lattice
- Output: reference to least element
Sourcefn ref_top(&self) -> &SafeElement<Self::Item>
fn ref_top(&self) -> &SafeElement<Self::Item>
Reference to greatest element of the lattice
- Output: reference to greatest element
Sourceunsafe fn unsafe_meet(
&self,
element_left: &Self::Item,
element_right: &Self::Item,
) -> Self::Item
unsafe fn unsafe_meet( &self, element_left: &Self::Item, element_right: &Self::Item, ) -> Self::Item
Unsafe greatest lower bound
- values are not tested to be within lattice.
- contract: operator should be associative
element_left: &Self::Item: left operandelement_right: &Self::Item: right operand- Output: unsafe greatest lower bound
Sourceunsafe fn unsafe_join(
&self,
element_left: &Self::Item,
element_right: &Self::Item,
) -> Self::Item
unsafe fn unsafe_join( &self, element_left: &Self::Item, element_right: &Self::Item, ) -> Self::Item
Unsafe least upper bound
- values are not tested to be within lattice.
- contract: operator should be associative!
element_left: &Self::Item: left operandelement_right: &Self::Item: right operand- Output: unsafe least upper bound
Provided Methods§
Sourcefn lattice_hash(&self) -> u128slx
fn lattice_hash(&self) -> u128slx
Lattice hash
- Output: lattice hash
Sourcefn bottom(&self) -> SafeElement<Self::Item>
fn bottom(&self) -> SafeElement<Self::Item>
Least element of the lattice
- Output: least element of the lattice
Sourcefn top(&self) -> SafeElement<Self::Item>
fn top(&self) -> SafeElement<Self::Item>
Greatest element of the lattice
- Output: greatest element of the lattice
Sourcefn is_bottom(
&self,
safe_element: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn is_bottom( &self, safe_element: &SafeElement<Self::Item>, ) -> Result<bool, String>
Is safe element the least element of the lattice?
safe_element: &SafeElement<Self::Item>: safe element- Output: boolean or error
Sourcefn is_top(&self, safe_element: &SafeElement<Self::Item>) -> Result<bool, String>
fn is_top(&self, safe_element: &SafeElement<Self::Item>) -> Result<bool, String>
Is safe element the greatest element of the lattice?
safe_element: &SafeElement<Self::Item>: safe element- Output: boolean or error
Sourceunsafe fn unsafe_is_bottom(&self, element: &Self::Item) -> bool
unsafe fn unsafe_is_bottom(&self, element: &Self::Item) -> bool
Is unsafe element the least element of the lattice?
element: &Self::Item: unsafe element- Output: boolean or error
Sourceunsafe fn unsafe_is_top(&self, element: &Self::Item) -> bool
unsafe fn unsafe_is_top(&self, element: &Self::Item) -> bool
Is unsafe element the greatest element of the lattice?
element: &Self::Item: unsafe element- Output: boolean or error
Sourcefn meet(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<SafeElement<Self::Item>, String>
fn meet( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<SafeElement<Self::Item>, String>
Greatest lower bound
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: greatest lower bound or error
Sourcefn meet_some<'a, I>(&self, it: I) -> Result<SafeElement<Self::Item>, String>
fn meet_some<'a, I>(&self, it: I) -> Result<SafeElement<Self::Item>, String>
Greatest lower bound of a collection
it: I: collection of safe elementsI: type of collection- Output: greatest lower bound or error
Sourcefn join(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<SafeElement<Self::Item>, String>
fn join( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<SafeElement<Self::Item>, String>
Least upper bound
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: least upper bound or error
Sourcefn join_some<'a, I>(&self, it: I) -> Result<SafeElement<Self::Item>, String>
fn join_some<'a, I>(&self, it: I) -> Result<SafeElement<Self::Item>, String>
Least upper bound of a collection
it: I: collection of safe elementsI: type of collection- Output: least upper bound or error
Sourcefn check_safe<T>(&self, element: T) -> Result<SafeElement<Self::Item>, String>
fn check_safe<T>(&self, element: T) -> Result<SafeElement<Self::Item>, String>
Check if unsafe element is in lattice and then build safe element
element: T: unsafe elementT: type of unsafe element; actually any type which implementInto<Self::Item>- Output: safe element or error
Sourcefn rand_elements<R: Rng, I>(
&self,
len: usize,
rng: &mut R,
) -> I::Type<SafeElement<Self::Item>>where
I: CollectionFamily1,
fn rand_elements<R: Rng, I>(
&self,
len: usize,
rng: &mut R,
) -> I::Type<SafeElement<Self::Item>>where
I: CollectionFamily1,
Elements collection generator (for tests); elements are built safe
len: usize: size of the collectionrng: &mut R: random number generatorR: Rng: type of random number generatorI: type of collection- Output: collection of random safe elements
Sourcefn assignment(&self) -> AssignmentBuilder<Self::Item>
fn assignment(&self) -> AssignmentBuilder<Self::Item>
Init a new assignment builder
- Output: empty assignment builder
Sourcefn assignment_with_capacity(
&self,
capacity: usize,
) -> AssignmentBuilder<Self::Item>
fn assignment_with_capacity( &self, capacity: usize, ) -> AssignmentBuilder<Self::Item>
Init a new assignment builder with capacity
capacity: usize: capacity- Output: empty assignment builder with capacity
capacity
Sourcefn prunable(
&self,
length_mid: u32,
length_max: u32,
) -> AssignmentBuilder<Self::Item>
fn prunable( &self, length_mid: u32, length_max: u32, ) -> AssignmentBuilder<Self::Item>
Init a new prunable assignment builder
length_mid: u32slx: max size of pruned assignmentlength_max: u32slx: max size of assignment- Output: empty assignment builder
Sourcefn prunable_with_capacity(
&self,
length_mid: u32,
length_max: u32,
capacity: usize,
) -> AssignmentBuilder<Self::Item>
fn prunable_with_capacity( &self, length_mid: u32, length_max: u32, capacity: usize, ) -> AssignmentBuilder<Self::Item>
Init a new prunable assignment builder with capacity
length_mid: u32slx: max size of pruned assignmentlength_max: u32slx: max size of assignmentcapacity: usize: capacity- Output: empty assignment builder with capacity
capacity
Sourceunsafe fn unsafe_cover(&self, left: &Self::Item, right: &Self::Item) -> bool
unsafe fn unsafe_cover(&self, left: &Self::Item, right: &Self::Item) -> bool
Unsafe test if left and right cover top, ie. union of left and right is top
left: &Self::Item: left operandright: &Self::Item: right operand- Output: boolean
Sourceunsafe fn unsafe_disjoint(&self, left: &Self::Item, right: &Self::Item) -> bool
unsafe fn unsafe_disjoint(&self, left: &Self::Item, right: &Self::Item) -> bool
Unsafe test if left and right are disjoint
left: &Self::Item: left operandright: &Self::Item: right operand- Output: boolean
Sourceunsafe fn unsafe_implies_join(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool
unsafe fn unsafe_implies_join( &self, left: &Self::Item, right: &Self::Item, ) -> bool
Unsafe test if left implies (i.e. is contained by) right
- should be equivalent to implies_meet
left: &Self::Item: left operandright: &Self::Item: right operand- Output: boolean
Sourceunsafe fn unsafe_implied_join(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool
unsafe fn unsafe_implied_join( &self, left: &Self::Item, right: &Self::Item, ) -> bool
Unsafe test if left is implied by (i.e. contains) right
- should be equivalent to implied_meet
left: &Self::Item: left operandright: &Self::Item: right operand- Output: boolean
Sourceunsafe fn unsafe_implies_meet(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool
unsafe fn unsafe_implies_meet( &self, left: &Self::Item, right: &Self::Item, ) -> bool
Unsafe test if left implies (i.e. is contained by) right
- should be equivalent to implies_join
left: &Self::Item: left operandright: &Self::Item: right operand- Output: boolean
Sourceunsafe fn unsafe_implied_meet(
&self,
left: &Self::Item,
right: &Self::Item,
) -> bool
unsafe fn unsafe_implied_meet( &self, left: &Self::Item, right: &Self::Item, ) -> bool
Unsafe test if left is implied by (i.e. contains) right
- should be equivalent to implied_joint
left: &Self::Item: left operandright: &Self::Item: right operand- Output: boolean
Sourcefn cover(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn cover( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<bool, String>
Test if left and right cover top, ie. union of left and right is top
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: boolean or error
Sourcefn disjoint(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn disjoint( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<bool, String>
Test if left and right are disjoint
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: boolean or error
Sourcefn implies_join(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn implies_join( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<bool, String>
Test if left implies (i.e. is contained by) right
- should be equivalent to implies_meet
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: boolean or error
Sourcefn implied_join(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn implied_join( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<bool, String>
Test if left is implied by (i.e. contains) right
- should be equivalent to implied_meet
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: boolean or error
Sourcefn implies_meet(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn implies_meet( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<bool, String>
Test if left implies (i.e. is contained by) right
- should be equivalent to implies_join
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: boolean or error
Sourcefn implied_meet(
&self,
left: &SafeElement<Self::Item>,
right: &SafeElement<Self::Item>,
) -> Result<bool, String>
fn implied_meet( &self, left: &SafeElement<Self::Item>, right: &SafeElement<Self::Item>, ) -> Result<bool, String>
Test if left is implied by (i.e. contains) right
- should be equivalent to implied_joint
left: &SafeElement<Self::Item>: left operandright: &SafeElement<Self::Item>: right operand- Output: boolean or error
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.