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
73
74
75
76
77
78
79
80
81
82
83
84
use std::fmt::{Display, Formatter, Result as FmtResult};
use rvi::LocalServices;
pub type UpdateRequestId = String;
#[allow(non_snake_case)]
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub struct UpdateRequest {
pub requestId: UpdateRequestId,
pub status: UpdateRequestStatus,
pub packageId: Package,
pub installPos: i32,
pub createdAt: String,
}
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub enum UpdateRequestStatus {
Pending,
InFlight,
Canceled,
Failed,
Finished
}
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub struct Package {
pub name: String,
pub version: String
}
impl Display for Package {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{} {}", self.name, self.version)
}
}
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub struct UpdateAvailable {
pub update_id: String,
pub signature: String,
pub description: String,
pub request_confirmation: bool,
pub size: u64
}
#[derive(RustcDecodable, RustcEncodable)]
pub struct DownloadStarted {
pub device: String,
pub update_id: UpdateRequestId,
pub services: LocalServices,
}
#[derive(RustcDecodable, RustcEncodable)]
pub struct ChunkReceived {
pub device: String,
pub update_id: UpdateRequestId,
pub chunks: Vec<u64>,
}
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub struct DownloadComplete {
pub update_id: String,
pub update_image: String,
pub signature: String
}
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub struct DownloadFailed {
pub update_id: String,
pub reason: String
}