#[non_exhaustive]pub enum InvalidUtf8 {
Lossy,
Strict,
}Expand description
Strategy for handling byte sequences that are not valid UTF-8 (or UTF-16).
Steam stores string values in binary VDF files as raw byte strings and does
not guarantee they are valid UTF-8. Localized fields in particular often
carry legacy code-page bytes (e.g. a Czech app name Moje Spore v\u{fffd}tvory
where 0xFD is Windows-1250 ý), which are not valid UTF-8 on their own.
This enum selects what the parser does when it encounters such bytes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Lossy
Replace invalid byte sequences with the U+FFFD REPLACEMENT CHARACTER.
Parsing always succeeds. Valid strings are still borrowed zero-copy from the input; only strings that actually contain invalid bytes are allocated (to hold the replacement characters). This is the default.
Strict
Return an Error::InvalidUtf8 (or
Error::InvalidUtf16) error.
Use this when you need to detect corruption rather than silently substituting replacement characters.
Trait Implementations§
Source§impl Clone for InvalidUtf8
impl Clone for InvalidUtf8
Source§fn clone(&self) -> InvalidUtf8
fn clone(&self) -> InvalidUtf8
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InvalidUtf8
Source§impl Debug for InvalidUtf8
impl Debug for InvalidUtf8
Source§impl Default for InvalidUtf8
impl Default for InvalidUtf8
Source§fn default() -> InvalidUtf8
fn default() -> InvalidUtf8
impl Eq for InvalidUtf8
Source§impl Hash for InvalidUtf8
impl Hash for InvalidUtf8
Source§impl PartialEq for InvalidUtf8
impl PartialEq for InvalidUtf8
impl StructuralPartialEq for InvalidUtf8
Auto Trait Implementations§
impl Freeze for InvalidUtf8
impl RefUnwindSafe for InvalidUtf8
impl Send for InvalidUtf8
impl Sync for InvalidUtf8
impl Unpin for InvalidUtf8
impl UnsafeUnpin for InvalidUtf8
impl UnwindSafe for InvalidUtf8
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.