network_interface/
error.rs1use std::string::{FromUtf16Error, FromUtf8Error};
2
3#[derive(thiserror::Error, Debug)]
4pub enum Error {
5 #[error("Failed to execute `{0}`. Received error code `{1}`")]
6 GetIfAddrsError(String, i32),
7 #[error("Failed to execute `{0}`. Received error code `{1}`")]
8 GetIfNameError(String, u32),
9 #[error("Failed to parse bytes into UTF-8 characters. `{0}`")]
10 ParseUtf8Error(FromUtf8Error),
11 #[error("Failed to parse bytes into UTF-16 characters. `{0}`")]
12 ParseUtf16Error(FromUtf16Error),
13}
14
15impl From<FromUtf8Error> for Error {
16 fn from(error: FromUtf8Error) -> Self {
17 Error::ParseUtf8Error(error)
18 }
19}
20
21impl From<FromUtf16Error> for Error {
22 fn from(error: FromUtf16Error) -> Self {
23 Error::ParseUtf16Error(error)
24 }
25}