pub struct FromUtf8Error { /* private fields */ }Expand description
An error from ByteString::from_utf8 that retains the original bytes.
Implementations§
Source§impl FromUtf8Error
impl FromUtf8Error
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Returns the original bytes without copying them.
§Examples
let bytes = bytes::Bytes::from_static(b"a\xff");
let err = ByteString::from_utf8(bytes).unwrap_err();
assert_eq!(err.into_bytes(), bytes::Bytes::from_static(b"a\xff"));Sourcepub const fn utf8_error(&self) -> Utf8Error
pub const fn utf8_error(&self) -> Utf8Error
Returns details of the UTF-8 validation failure.
§Examples
let bytes = bytes::Bytes::from_static(b"a\xff");
let err = ByteString::from_utf8(bytes).unwrap_err();
assert_eq!(err.utf8_error().valid_up_to(), 1);
assert_eq!(err.utf8_error().error_len(), Some(1));Trait Implementations§
Source§impl Clone for FromUtf8Error
impl Clone for FromUtf8Error
Source§impl Debug for FromUtf8Error
impl Debug for FromUtf8Error
Source§impl Display for FromUtf8Error
impl Display for FromUtf8Error
impl Eq for FromUtf8Error
Source§impl Error for FromUtf8Error
impl Error for FromUtf8Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for FromUtf8Error
impl PartialEq for FromUtf8Error
impl StructuralPartialEq for FromUtf8Error
Auto Trait Implementations§
impl !Freeze for FromUtf8Error
impl Forget for FromUtf8Error
impl RefUnwindSafe for FromUtf8Error
impl Send for FromUtf8Error
impl Sync for FromUtf8Error
impl Unpin for FromUtf8Error
impl UnsafeUnpin for FromUtf8Error
impl UnwindSafe for FromUtf8Error
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