sheave_core/messages/amf/
invalid_string.rs1use std::{
2 error::Error,
3 fmt::{
4 Display,
5 Formatter,
6 Result as FormatResult
7 },
8 io::{
9 Error as IOError,
10 ErrorKind
11 },
12 string::FromUtf8Error
13};
14
15#[derive(Debug)]
17pub struct InvalidString(FromUtf8Error);
18
19impl InvalidString {
20 pub fn new(e: FromUtf8Error) -> Self {
22 Self(e)
23 }
24}
25
26impl Display for InvalidString {
27 fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
28 Display::fmt(&self.0, f)
29 }
30}
31
32impl Error for InvalidString {}
33
34pub fn invalid_string(e: FromUtf8Error) -> IOError {
36 IOError::new(
37 ErrorKind::InvalidData,
38 InvalidString(e)
39 )
40}