pub struct Decoder { /* private fields */ }
Expand description
Decoder of byte slices into strings.
If feature encoding
is enabled, this encoding taken from the "encoding"
XML declaration or assumes UTF-8, if XML has no declaration, encoding
key is not defined or contains unknown encoding.
The library supports any UTF-8 compatible encodings that crate encoding_rs
is supported. UTF-16 and ISO-2022-JP are not supported at the present.
If feature encoding
is disabled, the decoder is always UTF-8 decoder:
any XML declarations are ignored.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub const fn encoding(&self) -> &'static Encoding
Available on crate feature encoding
only.
pub const fn encoding(&self) -> &'static Encoding
encoding
only.Returns the Reader
s encoding.
This encoding will be used by decode
.
Sourcepub fn decode<'b>(&self, bytes: &'b [u8]) -> Result<Cow<'b, str>, EncodingError>
pub fn decode<'b>(&self, bytes: &'b [u8]) -> Result<Cow<'b, str>, EncodingError>
§Without encoding
feature
Decodes an UTF-8 slice regardless of XML declaration and ignoring BOM
if it is present in the bytes
.
§With encoding
feature
Decodes specified bytes using encoding, declared in the XML, if it was
declared there, or UTF-8 otherwise, and ignoring BOM if it is present
in the bytes
.
Returns an error in case of malformed sequences in the bytes
.
Sourcepub fn decode_into(
&self,
bytes: &[u8],
buf: &mut String,
) -> Result<(), EncodingError>
pub fn decode_into( &self, bytes: &[u8], buf: &mut String, ) -> Result<(), EncodingError>
Like decode
but using a pre-allocated buffer.
Trait Implementations§
impl Copy for Decoder
impl Eq for Decoder
impl StructuralPartialEq for Decoder
Auto Trait Implementations§
impl Freeze for Decoder
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnwindSafe for Decoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)