pub struct Term<PT: ProtocolTypes> {
pub term: DYTerm<PT>,
pub payloads: Option<Payloads>,
}
Expand description
Term
s are Term
s equipped with optional Payloads
when they no longer are treated as
symbolic terms.
Fields§
§term: DYTerm<PT>
§payloads: Option<Payloads>
Implementations§
source§impl<PT: ProtocolTypes> Term<PT>
impl<PT: ProtocolTypes> Term<PT>
sourcepub(crate) fn eval_until_opaque<PB>(
&self,
eval_tree: &mut EvalTree,
ctx: &TraceContext<PB>,
with_payloads: bool,
sibling_has_payloads: bool,
type_term: &TypeShape<PT>,
) -> Result<(Box<dyn EvaluatedTerm<PT>>, Vec<PayloadContext<'_, PT>>), Error>where
PB: ProtocolBehavior<ProtocolTypes = PT>,
pub(crate) fn eval_until_opaque<PB>(
&self,
eval_tree: &mut EvalTree,
ctx: &TraceContext<PB>,
with_payloads: bool,
sibling_has_payloads: bool,
type_term: &TypeShape<PT>,
) -> Result<(Box<dyn EvaluatedTerm<PT>>, Vec<PayloadContext<'_, PT>>), Error>where
PB: ProtocolBehavior<ProtocolTypes = PT>,
Evaluate a term without replacing the payloads (returning the payloads with the
corresponding paths instead, i.e., a Vec<PayloadContext>
accumulator), except when
reaching an opaque term with payloads as strict sub-terms. In the latter case, fully
evaluate each of the arguments (and performing the payload replacements) before
evaluating the opaque function, which then needs to be read to convert it back to a
Box<dyn EvaluatedTerm<PT>>
. @path: current path of &self in the overall recipe (initially
[]). Invariant: Returns the payloads to replace in this order: deeper first, left-most
arguments first.
When with_payloads
is false, then this should be equivalent to evaluate_lazy_test
and it
always return empty PayloadContext
vectors.
source§impl<PT: ProtocolTypes> Term<PT>
impl<PT: ProtocolTypes> Term<PT>
sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
When the term starts with an opaque function symbol (like encryption)
sourcepub fn erase_payloads_subterms(&mut self, is_subterm: bool)
pub fn erase_payloads_subterms(&mut self, is_subterm: bool)
Erase all payloads in a term, including those under opaque function symbol
sourcepub fn add_payload(&mut self, payload: Vec<u8>)
pub fn add_payload(&mut self, payload: Vec<u8>)
Add a payload at the root position, erase payloads in strict sub-terms not under opaque
sourcepub fn make_payload<PB>(&mut self, ctx: &TraceContext<PB>) -> Result<(), Error>where
PB: ProtocolBehavior<ProtocolTypes = PT>,
pub fn make_payload<PB>(&mut self, ctx: &TraceContext<PB>) -> Result<(), Error>where
PB: ProtocolBehavior<ProtocolTypes = PT>,
Make and Add a payload at the root position, erase payloads in strict sub-terms not under opaque
sourcepub fn all_payloads(&self) -> Vec<&Payloads>
pub fn all_payloads(&self) -> Vec<&Payloads>
Return all payloads contains in a term, even under opaque terms.
Note that we keep the invariant that a non-symbolic term cannot have payloads in
struct-subterms, see add_payload/make_payload
.
sourcepub fn all_payloads_mut(&mut self) -> Vec<&mut Payloads>
pub fn all_payloads_mut(&mut self) -> Vec<&mut Payloads>
Return all payloads contains in a term (mutable references), even under opaque terms.
Note that we keep the invariant that a non-symbolic term cannot have payloads in
struct-subterms, see add_payload/make_payload
.
sourcepub fn payloads_to_replace(&self) -> Vec<&Payloads>
pub fn payloads_to_replace(&self) -> Vec<&Payloads>
Return all payloads contained in a term, except those under opaque terms. The deeper the first in the returned vector.
sourcepub fn has_payload_to_replace(&self) -> bool
pub fn has_payload_to_replace(&self) -> bool
Return whether there is at least one payload, except those under opaque terms.
sourcepub fn has_payload_to_replace_wo_root(&self) -> bool
pub fn has_payload_to_replace_wo_root(&self) -> bool
Return whether there is at least one payload, except those under opaque terms and at the root..
source§impl<PT: ProtocolTypes> Term<PT>
impl<PT: ProtocolTypes> Term<PT>
fn unique_id(&self, tree_mode: bool, cluster_id: usize) -> String
fn node_attributes( displayable: impl Display, color: &str, shape: &str, ) -> String
fn collect_statements( term: &Self, tree_mode: bool, cluster_id: usize, statements: &mut Vec<String>, )
sourcepub fn dot_subgraph(
&self,
tree_mode: bool,
cluster_id: usize,
label: &str,
) -> String
pub fn dot_subgraph( &self, tree_mode: bool, cluster_id: usize, label: &str, ) -> String
If tree_mode
is true then each subgraph is self-contained and does not reference other
clusters or nodes outside of this subgraph. Therefore, only trees are generated. If it is
false, then graphs are rendered.
source§impl<PT: ProtocolTypes> Term<PT>
impl<PT: ProtocolTypes> Term<PT>
pub fn count_functions_by_name(&self, find_name: &'static str) -> usize
Trait Implementations§
source§impl<'de, PT> Deserialize<'de> for Term<PT>where
PT: ProtocolTypes,
impl<'de, PT> Deserialize<'de> for Term<PT>where
PT: ProtocolTypes,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<PT: ProtocolTypes> Display for Term<PT>
impl<PT: ProtocolTypes> Display for Term<PT>
source§impl<'a, PT: ProtocolTypes> IntoIterator for &'a Term<PT>
impl<'a, PT: ProtocolTypes> IntoIterator for &'a Term<PT>
Having the same mutator for &’a mut DYTerm
is not possible in Rust:
source§impl<PT> Serialize for Term<PT>where
PT: ProtocolTypes,
impl<PT> Serialize for Term<PT>where
PT: ProtocolTypes,
source§impl<PT: ProtocolTypes> Subterms<PT, Term<PT>> for Vec<Term<PT>>
impl<PT: ProtocolTypes> Subterms<PT, Term<PT>> for Vec<Term<PT>>
source§fn find_subterm_same_shape(&self, term: &Term<PT>) -> Option<&Term<PT>>
fn find_subterm_same_shape(&self, term: &Term<PT>) -> Option<&Term<PT>>
Finds a subterm with the same type as term
source§fn find_subterm<P: Fn(&&Term<PT>) -> bool + Copy>(
&self,
predicate: P,
) -> Option<&Term<PT>>
fn find_subterm<P: Fn(&&Term<PT>) -> bool + Copy>( &self, predicate: P, ) -> Option<&Term<PT>>
Finds a subterm in this vector
source§fn filter_grand_subterms<P: Fn(&Term<PT>, &Term<PT>) -> bool + Copy>(
&self,
predicate: P,
) -> Vec<((usize, &Term<PT>), &Term<PT>)>
fn filter_grand_subterms<P: Fn(&Term<PT>, &Term<PT>) -> bool + Copy>( &self, predicate: P, ) -> Vec<((usize, &Term<PT>), &Term<PT>)>
Finds all grand children/subterms which match the predicate.
A grand subterm is defined as a subterm of a term in self
.
Each grand subterm is returned together with its parent and the index of the parent in
self
.
source§impl<PT: ProtocolTypes> TermType<PT> for Term<PT>
impl<PT: ProtocolTypes> TermType<PT> for Term<PT>
source§fn evaluate_config<PB>(
&self,
context: &TraceContext<PB>,
with_payloads: bool,
) -> Result<(ConcreteMessage, Box<dyn EvaluatedTerm<PT>>), Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
fn evaluate_config<PB>(
&self,
context: &TraceContext<PB>,
with_payloads: bool,
) -> Result<(ConcreteMessage, Box<dyn EvaluatedTerm<PT>>), Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
Evaluate terms into bitstrings and EvaluatedTerm
(considering Payloads)
fn resistant_id(&self) -> u32
fn is_leaf(&self) -> bool
fn get_type_shape(&self) -> &TypeShape<PT>
fn name(&self) -> &str
fn mutate(&mut self, other: Self)
fn display_at_depth(&self, depth: usize) -> String
fn is_symbolic(&self) -> bool
fn make_symbolic(&mut self)
source§fn evaluate<PB>(&self, ctx: &TraceContext<PB>) -> Result<ConcreteMessage, Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
fn evaluate<PB>(&self, ctx: &TraceContext<PB>) -> Result<ConcreteMessage, Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
ConcreteMessage
(considering Payloads)source§fn evaluate_symbolic<PB>(
&self,
ctx: &TraceContext<PB>,
) -> Result<ConcreteMessage, Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
fn evaluate_symbolic<PB>(
&self,
ctx: &TraceContext<PB>,
) -> Result<ConcreteMessage, Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
ConcreteMessage
considering all sub-terms as symbolic (even those with
Payloads)source§fn evaluate_dy<PB>(
&self,
ctx: &TraceContext<PB>,
) -> Result<Box<dyn EvaluatedTerm<PT>>, Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
fn evaluate_dy<PB>(
&self,
ctx: &TraceContext<PB>,
) -> Result<Box<dyn EvaluatedTerm<PT>>, Error>where
PB: ProtocolBehavior<ProtocolTypes = PT> + ProtocolBehavior,
EvaluatedTerm
considering all sub-terms as symbolic (even those with
Payloads)impl<PT: Eq + ProtocolTypes> Eq for Term<PT>
impl<PT: ProtocolTypes> StructuralPartialEq for Term<PT>
Auto Trait Implementations§
impl<PT> Freeze for Term<PT>
impl<PT> !RefUnwindSafe for Term<PT>
impl<PT> Send for Term<PT>
impl<PT> Sync for Term<PT>
impl<PT> Unpin for Term<PT>
impl<PT> !UnwindSafe for Term<PT>
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
§impl<T> CloneAny for T
impl<T> CloneAny for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
§type PreprendResult = Tail
type PreprendResult = Tail
TupleList
], of an [Prepend::prepend()
] call,
including the prepended entry.