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
use reqwest::Client;
use std::sync::RwLock;
pub const PROJECT: Option<&'static str> = option_env!("CARGO_PKG_NAME");
pub const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
const SUPPORTED_X_PLEX_SYNC_VERSION: &str = "2";
lazy_static! {
/// `X-Plex-Provides` header value.
///
/// Should be one or more of `controller`, `server`, `sync-target`, `player`.
pub static ref X_PLEX_PROVIDES: RwLock<&'static str> = RwLock::new("controller");
/// `X-Plex-Platform` header value.
///
/// Platform name, e.g. iOS, macOS, etc.
pub static ref X_PLEX_PLATFORM: RwLock<&'static str> = RwLock::new("");
/// `X-Plex-Platform-Version` header value.
///
/// OS version, e.g. 4.3.1
pub static ref X_PLEX_PLATFORM_VERSION: RwLock<&'static str> = RwLock::new("");
/// `X-Plex-Product` header value.
///
/// Application name, e.g. Laika, Plex Media Server, Media Link.
pub static ref X_PLEX_PRODUCT: RwLock<&'static str> = RwLock::new("");
/// `X-Plex-Version` header value.
///
/// Application version, e.g. 10.6.7.
pub static ref X_PLEX_VERSION: RwLock<&'static str> = RwLock::new("");
/// `X-Plex-Device` header value.
///
/// Device name and model number, e.g. iPhone3,2, Motorola XOOMâ„¢, LG5200TV.
pub static ref X_PLEX_DEVICE: RwLock<&'static str> = RwLock::new("");
/// `X-Plex-Device-Name` header value.
///
/// Primary name for the device, e.g. "Plex Web (Chrome)".
pub static ref X_PLEX_DEVICE_NAME: RwLock<&'static str> = RwLock::new("");
/// `X-Plex-Sync-Version` header value.
///
/// The lib supports only "2", but you can set any value at your own risk.
pub static ref X_PLEX_SYNC_VERSION: RwLock<&'static str> = RwLock::new(SUPPORTED_X_PLEX_SYNC_VERSION);
/// `X-Plex-Client-Identifier` header value.
///
/// UUID, serial number, or other number unique per device. Random value would be generated
/// if not set. Can be set by providing ENV-value `X_PLEX_CLIENT_IDENTIFIER`.
///
/// **N.B.** Should be unique across all your devices.
pub static ref X_PLEX_CLIENT_IDENTIFIER: RwLock<&'static str> = RwLock::new("");
pub static ref HTTP_CLIENT: RwLock<Client> = {
#[cfg(all(test, not(any(feature = "test_connect_authenticated", feature = "test_connect_anonymous"))))]
{
panic!("Client shouldn't be requested in this testing mode")
}
#[cfg(any(not(test), feature = "test_connect_authenticated", feature = "test_connect_anonymous"))]
{
use std::time::Duration;
RwLock::new(
Client::builder()
.timeout(Duration::from_secs(5))
.build()
.expect("HTTP_CLIENT init")
)
}
};
}