pub struct DeencodeTree {
pub input: String,
pub encoders: Vec<EncodeNode>,
}Expand description
The root of the deencoding tree.
Fields§
§input: StringThe input string.
encoders: Vec<EncodeNode>The underlying encoding steps.
Implementations§
Source§impl DeencodeTree
impl DeencodeTree
Sourcepub fn deencode(
input: &str,
engines: &[&dyn Engine],
depth: usize,
) -> DeencodeTree
pub fn deencode( input: &str, engines: &[&dyn Engine], depth: usize, ) -> DeencodeTree
Recursively call EncodeNode::make_nodes() and
DecodeNode::make_nodes() to build a deencoding tree for the given
input.
depth specify the number of encodings in any branch, and encodings
are always followed by decodings, so the actual depth of the generated
tree is 2 * depth.
The process starts with encoding, so you may not have depth == 0. (see
EncodeNode::make_nodes()’s documentation)
Sourcepub fn deduplicate(&mut self) -> (Vec<String>, Vec<Vec<u8>>)
pub fn deduplicate(&mut self) -> (Vec<String>, Vec<Vec<u8>>)
Prune the tree by only keeping one instance of any single encoding and decoding output.
Nodes are explored depth-first, in the same order as the engines slice
passed to DeencodeTree::deencode(), meaning earlier engines outputs
are kept over later engines.
Return the list of unique decodings (including the input, guaranteed to be in the first position), and the list of unique encodings.
Sourcepub fn box_drawings(&self, f: &mut Formatter<'_>) -> Result
pub fn box_drawings(&self, f: &mut Formatter<'_>) -> Result
Format the tree with box drawings, recursively.