Buttplug sex toy control library
1use buttplug_core::errors::ButtplugError;
2use buttplug_server::ButtplugServerError;
3use std::{error::Error, fmt};
4
5#[derive(Debug)]
6pub struct IntifaceError {
7 reason: String,
8}
9
10impl IntifaceError {
11 pub fn new(error_msg: &str) -> Self {
12 Self {
13 reason: error_msg.to_owned(),
14 }
15 }
16}
17
18impl fmt::Display for IntifaceError {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 write!(f, "{}", self.reason)
21 }
22}
23
24impl Error for IntifaceError {
25 fn source(&self) -> Option<&(dyn Error + 'static)> {
26 None
27 }
28}
29
30#[derive(Debug)]
31pub enum IntifaceEngineError {
32 IoError(std::io::Error),
33 ButtplugServerError(ButtplugServerError),
34 ButtplugError(ButtplugError),
35 IntifaceError(IntifaceError),
36}
37
38impl From<std::io::Error> for IntifaceEngineError {
39 fn from(err: std::io::Error) -> Self {
40 IntifaceEngineError::IoError(err)
41 }
42}
43
44impl From<ButtplugError> for IntifaceEngineError {
45 fn from(err: ButtplugError) -> Self {
46 IntifaceEngineError::ButtplugError(err)
47 }
48}
49
50impl From<IntifaceError> for IntifaceEngineError {
51 fn from(err: IntifaceError) -> Self {
52 IntifaceEngineError::IntifaceError(err)
53 }
54}