1use crate::TypeEvent;
2use std::fmt;
5
6pub struct ErrorAuthorize;
7
8impl std::error::Error for ErrorAuthorize {}
9
10impl fmt::Display for ErrorAuthorize {
11 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12 write!(
13 f,
14 "Failed to log in and access the camera. Check that your login and password are \
15 correct, and also check on the website in the Configuration -> Video/Audio -> \
16 \"Stream Type\" must be set to \"Sub-stream\". Also on this page set the value of \
17 the \"Video Encoding\" item to MPJPEG"
18 )
19 }
20}
21
22impl fmt::Debug for ErrorAuthorize {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 write!(
25 f,
26 "Failed to log in and access the camera. Check that your login and password are \
27 correct, and also check on the website in the Configuration -> Video/Audio -> \
28 \"Stream Type\" must be set to \"Sub-stream\". Also on this page set the value of \
29 the \"Video Encoding\" item to MPJPEG"
30 )
31 }
32}
33
34pub struct QuickRequsetError {
37 timeout: usize,
38 event: TypeEvent,
39}
40
41impl QuickRequsetError {
42 pub(crate) fn new(_timeout: usize, _event: TypeEvent) -> Self {
43 Self {
44 timeout: _timeout + 50,
45 event: _event,
46 }
47 }
48}
49
50impl std::error::Error for QuickRequsetError {}
51
52impl fmt::Display for QuickRequsetError {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 write!(
55 f,
56 "You are making request for the <{}> action too quickly. {}ms must have passed since \
57 the last request",
58 self.event.get_str(),
59 self.timeout
60 )
61 }
62}
63
64impl fmt::Debug for QuickRequsetError {
65 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
66 write!(
67 f,
68 "You are making request for the <{}> action too quickly. {}ms must have passed since \
69 the last request",
70 self.event.get_str(),
71 self.timeout
72 )
73 }
74}
75
76pub struct OutOfRangeUnitError {
78 data: i8,
79 event: TypeEvent,
80}
81
82impl OutOfRangeUnitError {
83 pub(crate) fn new(_data: i8, _event: TypeEvent) -> Self {
84 Self {
85 data: _data,
86 event: _event,
87 }
88 }
89}
90
91impl std::error::Error for OutOfRangeUnitError {}
92
93impl fmt::Display for OutOfRangeUnitError {
94 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
95 write!(
96 f,
97 "The unit of measurment for the <{}> event does ot lie in the range -100..=100, its \
98 value {}",
99 self.event.get_str(),
100 self.data
101 )
102 }
103}
104
105impl fmt::Debug for OutOfRangeUnitError {
106 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
107 write!(
108 f,
109 "The unit of measurment for the <{}> event does ot lie in the range -100..=100, its \
110 value {}",
111 self.event.get_str(),
112 self.data
113 )
114 }
115}