Trait encoding::types::EncodingStable
[-]
[+]
[src]
pub trait Encoding { fn name(&self) -> &'static str; fn encoder(&self) -> Box<Encoder>; fn decoder(&self) -> Box<Decoder>; fn whatwg_name(&self) -> Option<&'static str> { ... } fn encode(&self, input: &str, trap: EncoderTrap) -> Result<Vec<u8>, SendStr> { ... } fn decode(&self, input: &[u8], trap: DecoderTrap) -> Result<String, SendStr> { ... } }
Character encoding.
Required Methods
fn name(&self) -> &'static str
Returns the canonical name of given encoding. This name is guaranteed to be unique across built-in encodings, but it is not normative and would be at most arbitrary.
fn encoder(&self) -> Box<Encoder>
Creates a new encoder.
fn decoder(&self) -> Box<Decoder>
Creates a new decoder.
Provided Methods
fn whatwg_name(&self) -> Option<&'static str>
Returns a name of given encoding defined in the WHATWG Encoding standard, if any.
This name often differs from name
due to the compatibility reason.
fn encode(&self, input: &str, trap: EncoderTrap) -> Result<Vec<u8>, SendStr>
An easy-to-use interface to Encoder
.
On the encoder error trap
is called,
which may return a replacement sequence to continue processing,
or a failure to return the error.
fn decode(&self, input: &[u8], trap: DecoderTrap) -> Result<String, SendStr>
An easy-to-use interface to Decoder
.
On the decoder error trap
is called,
which may return a replacement string to continue processing,
or a failure to return the error.
Implementors
impl Encoding for ErrorEncoding
impl Encoding for ASCIIEncoding
impl Encoding for SingleByteEncoding
impl Encoding for UTF8Encoding
impl<E: Endian + Clone + 'static> Encoding for UTF16Encoding<E>
impl Encoding for Windows949Encoding
impl Encoding for EUCJPEncoding
impl Encoding for Windows31JEncoding
impl Encoding for ISO2022JPEncoding
impl Encoding for GB18030Encoding
impl Encoding for HZEncoding
impl Encoding for BigFive2003Encoding
impl Encoding for EncoderOnlyUTF8Encoding