pub struct ZipString { /* private fields */ }
Expand description
A string wrapper for handling different encodings.
Implementations§
Source§impl ZipString
impl ZipString
Sourcepub fn new(raw: Vec<u8>, encoding: StringEncoding) -> Self
pub fn new(raw: Vec<u8>, encoding: StringEncoding) -> Self
Constructs a new encoded string from its raw bytes and its encoding type.
§Note
If the provided encoding is StringEncoding::Utf8
but the raw bytes are not valid UTF-8 (ie. a call to
std::str::from_utf8()
fails), the encoding is defaulted back to StringEncoding::Raw
.
Sourcepub fn encoding(&self) -> StringEncoding
pub fn encoding(&self) -> StringEncoding
Returns the encoding type for this string.
Sourcepub fn as_str(&self) -> Result<&str>
pub fn as_str(&self) -> Result<&str>
Returns the raw bytes converted into a string slice.
§Note
A call to this method will only succeed if the encoding type is StringEncoding::Utf8
.
Sourcepub fn into_string(self) -> Result<String>
pub fn into_string(self) -> Result<String>
Returns the raw bytes converted to an owned string.
§Note
A call to this method will only succeed if the encoding type is StringEncoding::Utf8
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZipString
impl RefUnwindSafe for ZipString
impl Send for ZipString
impl Sync for ZipString
impl Unpin for ZipString
impl UnwindSafe for ZipString
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
Mutably borrows from an owned value. Read more