pub struct Term<PT: ProtocolTypes> {
pub term: DYTerm<PT>,
pub payloads: Option<Payloads>,
}Expand description
Terms are Terms 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 is_get(&self) -> bool
pub fn is_get(&self) -> bool
When the term starts with an opaque function symbol (like encryption)
Sourcepub fn is_no_bit(&self) -> bool
pub fn is_no_bit(&self) -> bool
When the term starts with a no_bit function symbol. We will never MakeMessage on, thus
disabling applying any of the bit-level mutations.
Sourcepub fn has_variable(&self) -> bool
pub fn has_variable(&self) -> bool
When the term has a variable as sub-term (excluding strict-sub-terms of readable)
Sourcepub fn has_no_det(&self) -> bool
pub fn has_no_det(&self) -> bool
When the term has a non-det sub-term (excluding strict-sub-terms of readable)
Sourcepub fn is_readable(&self) -> bool
pub fn is_readable(&self) -> bool
Whether the term is readable, i.e. whether it has a payload that will be read before evaluating
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_with_new(
&mut self,
payload_0: Vec<u8>,
payload_new: Vec<u8>,
with_metadata: Option<PayloadMetadata>,
)
pub fn add_payload_with_new( &mut self, payload_0: Vec<u8>, payload_new: Vec<u8>, with_metadata: Option<PayloadMetadata>, )
Add a payload at the root position and start with a new payload.payload possibly different from payload.payload_0, erase payloads in strict sub-terms not under opaque
Sourcepub fn add_payload(&mut self, payload_0: Vec<u8>)
pub fn add_payload(&mut self, payload_0: 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
Sourcepub fn add_payload_readable(&mut self, payload: ConcreteMessage)
pub fn add_payload_readable(&mut self, payload: ConcreteMessage)
Add a payload at the root position, erase payloads in strict sub-terms and make the payload readable.
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
strict-subterms, see add_payload/make_payload.
Sourcepub fn count_payloads(&self) -> usize
pub fn count_payloads(&self) -> usize
Number of payloads in a term, without allocating (unlike all_payloads().len(), which
materialises a Vec via the &Term iterator). Cheap enough for the hot mutation path.
Mirrors the iterator’s traversal exactly so the count equals all_payloads().len(): count
this node’s own payload, and recurse into sub-terms only while the node is symbolic (a
non-symbolic term keeps the invariant that it has no payloads in its strict sub-terms).
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
strict-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 or readable 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 or readable 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 or readable 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>
Having the same mutator for &’a mut DYTerm is not possible in Rust:
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: ProtocolBehavior<ProtocolTypes = PT>>(
&self,
context: &TraceContext<PB>,
with_payloads: bool,
) -> Result<(ConcreteMessage, Box<dyn EvaluatedTerm<PT>>), Error>
fn evaluate_config<PB: ProtocolBehavior<ProtocolTypes = PT>>( &self, context: &TraceContext<PB>, with_payloads: bool, ) -> Result<(ConcreteMessage, Box<dyn EvaluatedTerm<PT>>), Error>
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)
fn get(&self, path: &[usize]) -> Result<&Self, Error>
Source§fn evaluate_config_wrap<PB: ProtocolBehavior<ProtocolTypes = PT>>(
&self,
context: &TraceContext<PB>,
with_payloads: bool,
) -> Result<(ConcreteMessage, Box<dyn EvaluatedTerm<PT>>), Error>
fn evaluate_config_wrap<PB: ProtocolBehavior<ProtocolTypes = PT>>( &self, context: &TraceContext<PB>, with_payloads: bool, ) -> Result<(ConcreteMessage, Box<dyn EvaluatedTerm<PT>>), Error>
evaluate_config with error stats and logging handlingSource§fn evaluate<PB: ProtocolBehavior<ProtocolTypes = PT>>(
&self,
ctx: &TraceContext<PB>,
) -> Result<ConcreteMessage, Error>
fn evaluate<PB: ProtocolBehavior<ProtocolTypes = PT>>( &self, ctx: &TraceContext<PB>, ) -> Result<ConcreteMessage, Error>
ConcreteMessage (considering Payloads)Source§fn evaluate_symbolic<PB: ProtocolBehavior<ProtocolTypes = PT>>(
&self,
ctx: &TraceContext<PB>,
) -> Result<ConcreteMessage, Error>
fn evaluate_symbolic<PB: ProtocolBehavior<ProtocolTypes = PT>>( &self, ctx: &TraceContext<PB>, ) -> Result<ConcreteMessage, Error>
ConcreteMessage considering all sub-terms as symbolic (even those with
Payloads)Source§fn evaluate_dy<PB: ProtocolBehavior<ProtocolTypes = PT>>(
&self,
ctx: &TraceContext<PB>,
) -> Result<Box<dyn EvaluatedTerm<PT>>, Error>
fn evaluate_dy<PB: ProtocolBehavior<ProtocolTypes = PT>>( &self, ctx: &TraceContext<PB>, ) -> Result<Box<dyn EvaluatedTerm<PT>>, Error>
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§
§impl<Head, T> Append<T> for Head
impl<Head, T> Append<T> for Head
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,
§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
key and return true if they are equal.§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<I, S> MutatedTransform<I, S> for Iwhere
I: Clone,
S: HasCorpus<I>,
impl<I, S> MutatedTransform<I, S> for Iwhere
I: Clone,
S: HasCorpus<I>,
§fn try_transform_from(base: &mut Testcase<I>, state: &S) -> Result<I, Error>
fn try_transform_from(base: &mut Testcase<I>, state: &S) -> Result<I, Error>
§fn try_transform_into(
self,
_state: &S,
) -> Result<(I, <I as MutatedTransform<I, S>>::Post), Error>
fn try_transform_into( self, _state: &S, ) -> Result<(I, <I as MutatedTransform<I, S>>::Post), Error>
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more