Trait jomini::Encoding

source ·
pub trait Encoding {
    fn decode<'a>(&self, data: &'a [u8]) -> Cow<'a, str>;
}
Expand description

An encoding for interpreting byte data as UTF-8 text

Used in both text and binary format deserializers

It is heavily encouraged that encoding implementations are marked as Copy to make sure they are as cheap to copy as possible. In an experiment storing the encoding in a Rc resulted in a decrease of deserialization throughput by over 10%, as encodings are passed around everywhere.

An encoding should also perform additional actions when:

  • trailing whitespace is removed
  • escape sequences are unescaped

Required Methods§

Decodes bytes into a utf-8 compatible string – allocating if necessary

Implementations on Foreign Types§

Implementors§