pub struct Transformation { /* private fields */ }Expand description
A builder-style transformation of CBOR or EDN data.
A transformation encodes changes that can be applied to a Transformable such as a
StandaloneItem or a Sequence.
While methods on those and the application module provide fine
granularity and arbitrary operations, many use cases do not require the finest control – and
applying changes manually can lead to suboptimal results if not done in the right sequence.
Note that not all transformations have an effect for all input and output formats (any of CBOR-to-EDN, EDN-to-CBOR, EDN-to-EDN and CBOR-to-CBOR). For example, operations that influence indentation or comments have no practical effect when the transformation’s output is encoded to CBOR, and operations that decode application-oriented literals have no effect when the input is decoded from CBOR.
Implementations§
Source§impl Transformation
impl Transformation
pub fn apply_to<'a>(&self, item: &mut impl Transformable<'a>)
Source§impl Transformation
§Groups of transformations transformations
impl Transformation
§Groups of transformations transformations
Sourcepub const fn pretty(self) -> Self
pub const fn pretty(self) -> Self
Applies any transformation that making the EDN well-readable for humans.
Currently, this applies indentation and processes all known tags to produce corresponding application-oriented literals (or, in case of tags 2 and 3, to EDN numbers).
Sourcepub const fn for_cbor_serialization(self) -> Self
pub const fn for_cbor_serialization(self) -> Self
Applies the minimal transformations that are necessary for expressing general EDN as CBOR.
Currently, this is an alias for Self::aol_to_item() (and the author lacks the
imagination on whether this would ever need other transformations; the one that comes to
mind is converting big integers from EDN to CBOR, but that currently happens automatically
at serialization time).
Source§impl Transformation
§Single transformations
impl Transformation
§Single transformations
Sourcepub const fn indent(self) -> Self
pub const fn indent(self) -> Self
Applies some default indentation to the EDN.
Output will have a final newline if the general structure is multiline.
Sourcepub const fn indent_with_final_newline(self) -> Self
pub const fn indent_with_final_newline(self) -> Self
Applies some default indentation to the EDN.
Output will have a final newline unconditionally
Sourcepub const fn from_999(self) -> Self
pub const fn from_999(self) -> Self
Recognizes Tag 999 and turns it into application-oriented literals.
While this is mostly useful to obtain pretty EDN from an application that, knowing its domain CBOR, prepared tags for pretty-printing, it can also interact with other options that recognize application-oriented literals.
Sourcepub const fn to_999(self) -> Self
pub const fn to_999(self) -> Self
Produces Tag 999 for all application-oriented literals that are not converted to items in other steps.
This is applied last, after any other transformation option that process application-oriented literals.
Sourcepub const fn tag_to_aol(self) -> Self
pub const fn tag_to_aol(self) -> Self
Recognizes tags to produce application-oriented literals or annotations inside the tag.
pub const fn bignum_tag_to_edn_integer(self) -> Self
Sourcepub const fn aol_to_item(self) -> Self
pub const fn aol_to_item(self) -> Self
Turns recognized application-oriented literals into their CBOR items.
Sourcepub fn annotate_unwrapped_tag(self, tag_number: u64) -> Self
pub fn annotate_unwrapped_tag(self, tag_number: u64) -> Self
Annotates (by turning into an AOL, adding comments or processing nested items) the top-level structure .
pub fn annotate_cose_header_map(self) -> Self
Sourcepub const fn bytestring_heuristics(self) -> Self
pub const fn bytestring_heuristics(self) -> Self
Decides 'abc' and h'616263' based on its content
Trait Implementations§
Source§impl Clone for Transformation
impl Clone for Transformation
Source§fn clone(&self) -> Transformation
fn clone(&self) -> Transformation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more