autoendpoint/routers/apns/
settings.rs1use std::collections::HashMap;
2
3#[derive(Clone, Debug, serde::Deserialize)]
5#[serde(default)]
6#[serde(deny_unknown_fields)]
7pub struct ApnsSettings {
8 pub channels: String,
11 pub max_data: usize,
13 pub request_timeout_secs: Option<u64>,
17 pub pool_idle_timeout_secs: Option<u64>,
18}
19
20#[derive(Clone, Debug, Default, serde::Deserialize)]
22#[serde(default)]
23#[serde(deny_unknown_fields)]
24pub struct ApnsChannel {
25 pub cert: String,
29 pub key: String,
30 pub topic: Option<String>,
31 pub sandbox: bool,
32}
33
34impl Default for ApnsSettings {
35 fn default() -> ApnsSettings {
36 ApnsSettings {
37 channels: "{}".to_string(),
38 max_data: 4096,
39 request_timeout_secs: Some(20),
40 pool_idle_timeout_secs: Some(600),
41 }
42 }
43}
44
45impl ApnsSettings {
46 pub fn channels(&self) -> serde_json::Result<HashMap<String, ApnsChannel>> {
48 serde_json::from_str(&self.channels)
49 }
50}