pub struct EncodeError { /* private fields */ }
Expand description
The error returned by zalgo_encode
, ZalgoString::new
, and zalgo_wrap_python
if they encounter a byte they can not encode.
Implementations§
Source§impl EncodeError
impl EncodeError
Sourcepub const fn line(&self) -> usize
pub const fn line(&self) -> usize
Returns the 1-indexed line number of the line on which the unencodable byte occured.
§Examples
assert_eq!(zalgo_encode("❤️").map_err(|e| e.line()), Err(1));
assert_eq!(zalgo_encode("a\nb\nc\r\n").map_err(|e| e.line()), Err(3));
Sourcepub const fn column(&self) -> usize
pub const fn column(&self) -> usize
Returns the 1-indexed column where the unencodable byte occured. Columns are counted from left to right and the count resets for each new line.
§Example
assert_eq!(zalgo_encode("I ❤️ 🎂").map_err(|e| e.column()), Err(3));
assert_eq!(zalgo_encode("I\n❤️\n🎂").map_err(|e| e.column()), Err(1));
Sourcepub const fn char(&self) -> char
pub const fn char(&self) -> char
Returns the unencodable character that caused the error.
This may not match with what you see when you look at the unencoded string in a text editor since some grapheme clusters consist of many unicode characters.
§Examples
assert_eq!(zalgo_encode("CRLF\r\n").map_err(|e| e.char()), Err('\r'));
The ❤️ emoji consists of two characters, the heart U+2764
and the color variant selector U+FE0F
.
Since the heart is not encodable, that is the place where the error is generated:
assert_eq!(zalgo_encode("❤️").map_err(|e| e.char()), Err('❤'));
The grapheme cluster á
consists of a normal a
and a combining acute accent, U+301
.
The a
can be encoded and the combining acute accent can not, so the error points only to the accent:
assert_eq!(zalgo_encode("á").map_err(|e| e.char()), Err('\u{301}'))
Sourcepub const fn index(&self) -> usize
pub const fn index(&self) -> usize
Returns the index of the string where the unencodable character occured.
§Example
assert_eq!(zalgo_encode("ab\ncdë").map_err(|e| e.index()), Err(5));
Sourcepub fn backtrace(&self) -> &Backtrace
Available on crate feature std
only.
pub fn backtrace(&self) -> &Backtrace
std
only.Returns a reference to a Backtrace
that was captured when the error was created.
See the documentation of Backtrace::capture
for more information about how to make it
show more information when displayed.
Trait Implementations§
Source§impl Debug for EncodeError
impl Debug for EncodeError
Source§impl Display for EncodeError
impl Display for EncodeError
Source§impl Error for EncodeError
impl Error for EncodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl !Freeze for EncodeError
impl RefUnwindSafe for EncodeError
impl Send for EncodeError
impl Sync for EncodeError
impl Unpin for EncodeError
impl UnwindSafe for EncodeError
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.