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>>
pub fn decode<'b>(&self, bytes: &'b [u8]) -> Result<Cow<'b, str>>
§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
.
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
)