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
85
86
87
88
89
90
91
92
93
94
95
96
97
use crate::;
use error;
use Serialize;
use Value;
use HashMap;
/// Attempt to extract data from provided Protobuf bytes. Returns a `HashMap` representing the Protobuf data
///
/// # Example
/// ```rust
/// let proto_bytes = [
/// 10, 45, 99, 111, 109, 46, 97, 112, 112, 108, 101, 46, 97, 112, 112, 115, 116, 111, 114,
/// 101, 100, 46, 77, 105, 103, 114, 97, 116, 111, 114, 77, 105, 115, 99, 101, 108, 108,
/// 97, 110, 101, 111, 117, 115, 84, 97, 115, 107, 10, 40, 99, 111, 109, 46, 97, 112, 112,
/// 108, 101, 46, 97, 112, 112, 115, 116, 111, 114, 101, 100, 46, 77, 105, 103, 114, 97,
/// 116, 111, 114, 65, 112, 112, 85, 115, 97, 103, 101, 84, 97, 115, 107, 10, 38, 99, 111,
/// 109, 46, 97, 112, 112, 108, 101, 46, 97, 112, 112, 115, 116, 111, 114, 101, 100, 46,
/// 77, 105, 103, 114, 97, 116, 111, 114, 65, 114, 99, 97, 100, 101, 84, 97, 115, 107];
/// let proto_map = sunlight::light::extract_protobuf(&proto_bytes).unwrap();
/// assert_eq!(
/// proto_map.get(&1).unwrap().value,
/// serde_json::Value::Array(vec![
/// serde_json::Value::String(String::from("com.apple.appstored.MigratorMiscellaneousTask")),
/// serde_json::Value::String(String::from("com.apple.appstored.MigratorAppUsageTask")),
/// serde_json::Value::String(String::from("com.apple.appstored.MigratorArcadeTask"))]));
/// assert_eq!(proto_map.get(&1).unwrap().tag.wire_type, sunlight::light::WireType::Len);
/// ```
/** ```json
JSON representation
{
"1": {
"tag": {
"field": 1,
"tag_byte": 10,
"wire_type": "Len"
},
"value": [
"com.apple.appstored.MigratorMiscellaneousTask",
"com.apple.appstored.MigratorAppUsageTask",
"com.apple.appstored.MigratorArcadeTask"
]
}
}
```
*/