ffizz_string/
error.rs

1use std::error::Error;
2use std::fmt;
3
4/// InvalidUTF8Error indicates that the string contains invalid UTF-8 and could not be
5/// represented as a Rust string.
6#[derive(Eq, PartialEq, Debug)]
7pub struct InvalidUTF8Error;
8
9impl fmt::Display for InvalidUTF8Error {
10    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11        write!(f, "value contains invalid UTF-8 bytes")
12    }
13}
14
15impl Error for InvalidUTF8Error {}
16
17/// EmbeddedNulError indicates that the string contains embedded NUL bytes and
18/// could not be represented as a C string.
19#[derive(Eq, PartialEq, Debug)]
20pub struct EmbeddedNulError;
21
22impl fmt::Display for EmbeddedNulError {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        write!(f, "value contains embedded NUL bytes")
25    }
26}
27
28impl Error for EmbeddedNulError {}