1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
error_chain! {
errors {
AVTransportError(error: AVTransportError) {
description("An error occurred from AVTransport")
display("Received error {:?} from Sonos speaker", error)
}
ParseError {
description("An error occurred when attempting to parse SOAP XML from Sonos")
display("Failed to parse Sonos response XML")
}
DeviceUnreachable {
description("An error occurred when attempting to contact the device")
display("Failed to call Sonos endpoint")
}
BadResponse {
description("The device returned a bad response")
display("Received a non-success response from Sonos")
}
DeviceNotFound(identifier: String) {
description("An error occurred when trying to find device")
display("Couldn't find a device by the given identifier ({})", identifier)
}
}
foreign_links {
Discovery(::discovery::SSDPError) #[doc = "An error occurred while attempting to discover devices"];
XMLParse(::device::ParseError) #[doc = "An error occurred while parsing device response"];
}
}
impl From<AVTransportError> for ErrorKind {
fn from(error: AVTransportError) -> Self {
ErrorKind::AVTransportError(error)
}
}
#[derive(Debug)]
pub enum AVTransportError {
InvalidAction = 401,
InvalidArgs = 402,
InvalidVar = 404,
ActionFailed = 501,
TransitionNotAvailable = 701,
NoContents = 702,
ReadError = 703,
FormatNotSupported = 704,
TransportLocked = 705,
WriteError = 706,
MediaNotWriteable = 707,
RecordingFormatNotSupported = 708,
MediaFull = 709,
SeekModeNotSupported = 710,
IllegalSeekTarget = 711,
PlayModeNotSupported = 712,
RecordQualityNotSupported = 713,
IllegalMimeType = 714,
ContentBusy = 715,
PlaySpeedNotSupported = 717,
InvalidInstanceId = 718,
NoDnsServer = 737,
BadDomainName = 738,
ServerError = 739,
Unknown,
}
impl From<u64> for AVTransportError {
fn from(code: u64) -> AVTransportError {
match code {
401 => AVTransportError::InvalidAction,
402 => AVTransportError::InvalidArgs,
404 => AVTransportError::InvalidVar,
501 => AVTransportError::ActionFailed,
701 => AVTransportError::TransitionNotAvailable,
702 => AVTransportError::NoContents,
703 => AVTransportError::ReadError,
704 => AVTransportError::FormatNotSupported,
705 => AVTransportError::TransportLocked,
706 => AVTransportError::WriteError,
707 => AVTransportError::MediaNotWriteable,
708 => AVTransportError::RecordingFormatNotSupported,
709 => AVTransportError::MediaFull,
710 => AVTransportError::SeekModeNotSupported,
711 => AVTransportError::IllegalSeekTarget,
712 => AVTransportError::PlayModeNotSupported,
713 => AVTransportError::RecordQualityNotSupported,
714 => AVTransportError::IllegalMimeType,
715 => AVTransportError::ContentBusy,
717 => AVTransportError::PlaySpeedNotSupported,
718 => AVTransportError::InvalidInstanceId,
737 => AVTransportError::NoDnsServer,
738 => AVTransportError::BadDomainName,
739 => AVTransportError::ServerError,
_ => AVTransportError::Unknown,
}
}
}