pub trait Encoding: EncodingClone + AsCodePageMark {
    fn decode<'a>(&self, bytes: &'a [u8]) -> Result<Cow<'a, str>, DecodeError>;
    fn encode<'a>(&self, s: &'a str) -> Result<Cow<'a, [u8]>, EncodeError>;
}
Expand description

Trait for reading strings from the database files.

If the yore feature isn’t on, this is implemented only by UnicodeLossy and Unicode.

If the yore feature is on, this is implemented by all [yore::CodePage].

Note: This trait might be extended with an encode function in the future.

Required Methods

Decode encoding into UTF-8 string. If codepoints can’t be represented, an error is returned.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Implementors

Tries to decode as ASCII, if unrepresentable characters are found, an Err is returned.

Tries to decode as Unicode, if unrepresentable characters are found, an Err is returned.

Tries to decode as Unicode, replaces unknown codepoints with the replacement character.