[−][src]Trait serde_reflection::FormatHolder
Common methods for nodes in the AST of formats.
Required methods
fn visit<'a>(
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
Visit all the formats in self
in a depth-first way.
Variables are not supported and will cause an error.
fn visit_mut(
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
Mutably visit all the formats in self
in a depth-first way.
- Replace variables (if any) with their known values then apply the
visiting function
f
. - Return an error if any variable has still an unknown value (thus cannot be removed).
fn unify(&mut self, other: Self) -> Result<()>
Update variables and add missing enum variants so that the terms match. This is a special case of term unification:
- Variables occurring in
other
must be "fresh" and distinct from each other. By "fresh", we mean that they do not occur inself
and have no known value yet. - If needed, enums in
self
will be extended with new variants taken fromother
. - Although the parameter
other
is consumed (i.e. taken by value), all variables occurring either inself
orother
are correctly updated.
fn is_unknown(&self) -> bool
Whether this format is a variable with no known value yet.
Provided methods
fn normalize(&mut self) -> Result<()>
Finalize the formats within self
by removing variables and making sure
that all eligible tuples are compressed into a TupleArray
. Return an error
if any variable has an unknown value.
fn reduce(&mut self)
Attempt to remove known variables within self
. Silently abort
if some variables have unknown values.
Implementors
impl FormatHolder for ContainerFormat
[src]
fn visit<'a>(
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
[src]
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
fn visit_mut(
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
[src]
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
fn unify(&mut self, format: ContainerFormat) -> Result<()>
[src]
fn is_unknown(&self) -> bool
[src]
impl FormatHolder for Format
[src]
fn visit<'a>(
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
[src]
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
fn visit_mut(
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
[src]
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
fn unify(&mut self, format: Format) -> Result<()>
[src]
Unify the newly "traced" value format
into the current format.
Note that there should be no TupleArray
s at this point.
fn is_unknown(&self) -> bool
[src]
impl FormatHolder for VariantFormat
[src]
fn visit<'a>(
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
[src]
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
fn visit_mut(
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
[src]
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
fn unify(&mut self, format: VariantFormat) -> Result<()>
[src]
fn is_unknown(&self) -> bool
[src]
impl<T> FormatHolder for Named<T> where
T: FormatHolder + Debug,
[src]
T: FormatHolder + Debug,
fn visit<'a>(
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
[src]
&'a self,
f: &mut dyn FnMut(&'a Format) -> Result<()>
) -> Result<()>
fn visit_mut(
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
[src]
&mut self,
f: &mut dyn FnMut(&mut Format) -> Result<()>
) -> Result<()>
fn unify(&mut self, other: Named<T>) -> Result<()>
[src]
fn is_unknown(&self) -> bool
[src]
impl<T> FormatHolder for Variable<T> where
T: FormatHolder + Debug + Clone,
[src]
T: FormatHolder + Debug + Clone,