pub trait BaconCodec {
type ABTYPE;
type CONTENT;
// Required methods
fn encode_elem(&self, elem: &Self::CONTENT) -> Vec<Self::ABTYPE>;
fn decode_elems(&self, elems: &[Self::ABTYPE]) -> Self::CONTENT;
fn a(&self) -> Self::ABTYPE;
fn b(&self) -> Self::ABTYPE;
fn encoded_group_size(&self) -> usize;
fn is_a(&self, elem: &Self::ABTYPE) -> bool;
fn is_b(&self, elem: &Self::ABTYPE) -> bool;
// Provided methods
fn encode(&self, input: &[Self::CONTENT]) -> Vec<Self::ABTYPE> { ... }
fn decode(&self, input: &[Self::ABTYPE]) -> Vec<Self::CONTENT> { ... }
}
Expand description
A codec that enables encoding and decoding based on the Bacon’s cipher
Required Associated Types§
Required Methods§
Sourcefn encode_elem(&self, elem: &Self::CONTENT) -> Vec<Self::ABTYPE>
fn encode_elem(&self, elem: &Self::CONTENT) -> Vec<Self::ABTYPE>
Encodes a single emenent of Self::CONTENT
to a Vec of Self::ABTYPE
.
Sourcefn decode_elems(&self, elems: &[Self::ABTYPE]) -> Self::CONTENT
fn decode_elems(&self, elems: &[Self::ABTYPE]) -> Self::CONTENT
Decode an array of elements to produce one element of Self::CΟΝΤΕΝΤ
Sourcefn encoded_group_size(&self) -> usize
fn encoded_group_size(&self) -> usize
Returns the the size of the group of elements that represent a content encoding.
E.g.: For the default Bacon’s cipher, this is 5.