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
#![warn(missing_docs)]
#![deny(missing_debug_implementations, missing_copy_implementations,
trivial_casts, trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces, unused_qualifications)]
#[macro_use]
extern crate error_chain;
extern crate dbus;
#[allow(missing_docs)]
pub mod errors {
error_chain!{
foreign_links {
DBusError(::dbus::Error);
}
errors {
NoPlayerFound {
description("No player found")
display("Could not find a compatible MPRIS2 player running right now.")
}
TrackIdMissing {
description("track_id missing")
display("mpris:trackid not present in metadata")
}
InvalidPlaybackStatus(value: String) {
description("invalid PlaybackStatus value")
display("PlaybackStatus must be one of Playing, Paused, Stopped, but was {}", value)
}
DBusCallError(message: String) {
description("D-Bus call failed")
display("D-Bus call failed: {}", message)
}
}
}
}
mod generated;
mod extensions;
mod pooled_connection;
mod find;
mod metadata;
mod player;
mod progress;
mod prelude {
pub use errors::*;
}
pub use find::PlayerFinder;
pub use metadata::Metadata;
pub use player::Player;
pub use progress::{Progress, ProgressTracker};
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[allow(missing_docs)]
pub enum PlaybackStatus {
Playing,
Paused,
Stopped,
}
impl ::std::str::FromStr for PlaybackStatus {
type Err = errors::Error;
fn from_str(string: &str) -> Result<Self, Self::Err> {
use PlaybackStatus::*;
match string {
"Playing" => Ok(Playing),
"Paused" => Ok(Paused),
"Stopped" => Ok(Stopped),
other => Err(
errors::ErrorKind::InvalidPlaybackStatus(other.to_owned()).into(),
),
}
}
}