plex_api/myplex/sharing/
shareables.rs1use crate::{library::Library, MyPlex, Server};
2
3pub enum ShareableServer<'a> {
4 MachineIdentifier(&'a str),
5 Server(&'a Server),
6}
7
8impl<'a> ShareableServer<'a> {
9 pub fn id(&self) -> &str {
10 match self {
11 Self::MachineIdentifier(id) => id,
12 Self::Server(srv) => srv.machine_identifier(),
13 }
14 }
15}
16
17pub enum ShareableLibrary<'a> {
18 Library(&'a Library),
19 LibraryId(&'a str),
20}
21
22impl<'a> ShareableLibrary<'a> {
23 pub fn id(&self) -> &str {
24 match self {
25 Self::Library(library) => library.id(),
26 Self::LibraryId(id) => id,
27 }
28 }
29}
30
31pub enum User<'a> {
32 Account(&'a MyPlex),
33 UsernameOrEmail(&'a str),
34}
35
36impl<'a> User<'a> {
37 pub fn id(&self) -> &str {
38 match self {
39 Self::Account(MyPlex {
40 account: Some(account),
41 ..
42 }) => &account.email,
43 Self::Account(_) => "",
44 Self::UsernameOrEmail(u) => u,
45 }
46 }
47}