pub trait Decode: Sized {
// Required methods
fn decode(encoding: AbsoluteEncoding, terminals: Vec<Terminal>) -> Self;
fn remove_dummy_nodes(&mut self) -> Result<(), Error>;
}Expand description
Decode trait.
Defines methods how to construct trees from encodings.
Required Methods§
Sourcefn decode(encoding: AbsoluteEncoding, terminals: Vec<Terminal>) -> Self
fn decode(encoding: AbsoluteEncoding, terminals: Vec<Terminal>) -> Self
Construct a tree from an absolute scale encoding.
Decoding from a RelativeEncoding requires conversion into an AbsoluteEncoding:
use lumberjack::Tree;
use lumberjack::io::{AbsoluteEncoding, Encode, Decode, PTBFormat};
let tree = PTBFormat::Simple.string_to_tree("(Some (Test tree))").unwrap();
let terminals = tree.terminals().map(|t| tree[t].terminal().unwrap().clone()).collect::<Vec<_>>();
let relative_encoding = tree.encode_relative().unwrap();
let absolute = AbsoluteEncoding::try_from_relative(relative_encoding).unwrap_or_fix();
let tree = Tree::decode(absolute, terminals);fn remove_dummy_nodes(&mut self) -> Result<(), Error>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.