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 ErrorEncodingimpl Encoding for ASCIIEncodingimpl Encoding for SingleByteEncodingimpl Encoding for UTF8Encodingimpl<E: Endian + Clone + 'static> Encoding for UTF16Encoding<E>impl Encoding for Windows949Encodingimpl Encoding for EUCJPEncodingimpl Encoding for Windows31JEncodingimpl Encoding for ISO2022JPEncodingimpl Encoding for GB18030Encodingimpl Encoding for HZEncodingimpl Encoding for BigFive2003Encodingimpl Encoding for EncoderOnlyUTF8Encoding