summaryrefslogtreecommitdiff
path: root/vendored/mpd/src/mount.rs
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2022-08-07 20:47:54 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2022-08-07 20:47:54 -0400
commitea77a8cf9c012fcd877d842fec85b0b5a442952c (patch)
tree7f209c030b97a957497f152d161a9d7035311132 /vendored/mpd/src/mount.rs
parent0de7e9ac43f88aae3750ecfe25b5454fdd1ad015 (diff)
Import modifications to `mpd` crateHEADmaster
Diffstat (limited to 'vendored/mpd/src/mount.rs')
-rw-r--r--vendored/mpd/src/mount.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendored/mpd/src/mount.rs b/vendored/mpd/src/mount.rs
new file mode 100644
index 0000000..2c9558e
--- /dev/null
+++ b/vendored/mpd/src/mount.rs
@@ -0,0 +1,51 @@
+//! The module describes data structures for MPD (virtual) mounts system
+//!
+//! This mounts has nothing to do with system-wide Unix mounts, as they are
+//! implemented inside MPD only, so they doesn't require root access.
+//!
+//! The MPD mounts are plugin-based, so MPD can mount any resource as
+//! a source of songs for its database (like network shares).
+//!
+//! Possible, but inactive, mounts are named "neighbors" and can be
+//! listed with `neighbors()` method.
+
+use crate::convert::FromMap;
+use crate::error::{Error, ProtoError};
+
+use std::collections::BTreeMap;
+
+/// Mount point
+#[derive(Clone, Debug, PartialEq, RustcEncodable)]
+pub struct Mount {
+ /// mount point name
+ pub name: String,
+ /// mount storage URI
+ pub storage: String,
+}
+
+impl FromMap for Mount {
+ fn from_map(map: BTreeMap<String, String>) -> Result<Mount, Error> {
+ Ok(Mount {
+ name: map.get("mount").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("mount")))?,
+ storage: map.get("storage").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("storage")))?,
+ })
+ }
+}
+
+/// Neighbor
+#[derive(Clone, Debug, PartialEq, RustcEncodable)]
+pub struct Neighbor {
+ /// neighbor name
+ pub name: String,
+ /// neighbor storage URI
+ pub storage: String,
+}
+
+impl FromMap for Neighbor {
+ fn from_map(map: BTreeMap<String, String>) -> Result<Neighbor, Error> {
+ Ok(Neighbor {
+ name: map.get("name").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("name")))?,
+ storage: map.get("neighbor").map(|s| s.to_owned()).ok_or(Error::Proto(ProtoError::NoField("neighbor")))?,
+ })
+ }
+}