#![allow(clippy::module_name_repetitions)]
use std::{
error,
fmt::{self, Debug, Display, Formatter},
str,
string,
};
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Utf8Error {
inner: str::Utf8Error,
}
impl Utf8Error {
pub(super) fn from_std(std: str::Utf8Error) -> Self {
Self { inner: std }
}
#[inline]
pub fn valid_up_to(&self) -> usize {
self.inner.valid_up_to()
}
#[inline]
pub fn error_len(&self) -> Option<usize> {
self.inner.error_len()
}
}
impl Debug for Utf8Error {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
Debug::fmt(&self.inner, fmt)
}
}
impl Display for Utf8Error {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
Display::fmt(&self.inner, fmt)
}
}
impl error::Error for Utf8Error {}
pub struct Utf16Error {
pub(super) inner: string::FromUtf16Error,
}
impl Utf16Error {
pub(super) fn from_std(std: string::FromUtf16Error) -> Self {
Self { inner: std }
}
}
impl Debug for Utf16Error {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
Debug::fmt(&self.inner, fmt)
}
}
impl Display for Utf16Error {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
Display::fmt(&self.inner, fmt)
}
}
impl error::Error for Utf16Error {}