Trait jomini::Encoding[][src]

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

An encoding for interpreting byte data as UTF-8 text

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