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
use crate::{library::Library, MyPlex, Server};
pub enum ShareableServer<'a> {
MachineIdentifier(&'a str),
Server(&'a Server),
}
impl<'a> ShareableServer<'a> {
pub fn id(&self) -> &str {
match self {
Self::MachineIdentifier(id) => id,
Self::Server(srv) => srv.machine_identifier(),
}
}
}
pub enum ShareableLibrary<'a> {
Library(&'a Library),
LibraryId(&'a str),
}
impl<'a> ShareableLibrary<'a> {
pub fn id(&self) -> &str {
match self {
Self::Library(library) => library.id(),
Self::LibraryId(id) => id,
}
}
}
pub enum User<'a> {
Account(&'a MyPlex),
UsernameOrEmail(&'a str),
}
impl<'a> User<'a> {
pub fn id(&self) -> &str {
match self {
Self::Account(MyPlex {
account: Some(account),
..
}) => &account.email,
Self::Account(_) => "",
Self::UsernameOrEmail(u) => u,
}
}
}