resp_async/
error.rs

1use std::{error, io};
2
3pub type Error = io::Error;
4pub type Result<T> = io::Result<T>;
5
6pub(crate) fn to_error<E>(e: E) -> Error
7where
8    E: error::Error + Send + Sync + 'static,
9{
10    Error::new(io::ErrorKind::InvalidData, e)
11}
12
13pub(crate) fn invalid_data<A, T>(msg: T) -> Result<A>
14where
15    T: Into<Option<String>>,
16{
17    Err(if let Some(msg) = msg.into() {
18        Error::new(io::ErrorKind::InvalidData, msg)
19    } else {
20        io::ErrorKind::InvalidData.into()
21    })
22}