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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use std::collections::HashMap;
use crate::sled_json::{ TreeWrapper, JSONEncoder };
use crate::public_struct::{ ImageLayerLayerDiffIDToLayerDigestJSONValue,ImageLayerLayerDigestToLayerDiffIDJSONValue };
pub async fn record_image_digest_layer_diff_id_to_layer_digest(db: &sled::Db,image_digest:String,layer_diff_id:String,layer_digest:String) -> sled::Result<()> {
let tree = TreeWrapper::<JSONEncoder<ImageLayerLayerDiffIDToLayerDigestJSONValue>, JSONEncoder<ImageLayerLayerDiffIDToLayerDigestJSONValue>>::new(
db.open_tree("image_digest_layerdiffid_to_layerdigest")?,
);
let value = tree
.get(image_digest.clone());
let image_digest_json_value;
match value {
Ok(res) => {
match res {
Some(res1) =>{
match res1.decode() {
Some(mut res2) => {
res2.image_digest_layerdiffid_to_layerdigest.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDiffIDToLayerDigestJSONValue {
image_digest_layerdiffid_to_layerdigest: res2.image_digest_layerdiffid_to_layerdigest
};
}
_ => {
let mut image_digest_layerdiffid_to_layerdigest = HashMap::new();
image_digest_layerdiffid_to_layerdigest.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDiffIDToLayerDigestJSONValue {
image_digest_layerdiffid_to_layerdigest
};
}
}
},
_ => {
let mut image_digest_layerdiffid_to_layerdigest = HashMap::new();
image_digest_layerdiffid_to_layerdigest.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDiffIDToLayerDigestJSONValue {
image_digest_layerdiffid_to_layerdigest
};
}
}
},
Err(_) => {
let mut image_digest_layerdiffid_to_layerdigest = HashMap::new();
image_digest_layerdiffid_to_layerdigest.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDiffIDToLayerDigestJSONValue {
image_digest_layerdiffid_to_layerdigest
};
}
};
tree.insert(image_digest.clone(), &image_digest_json_value)?;
Ok(())
}
pub async fn record_image_digest_layer_digest_layer_diff_id(db: &sled::Db,image_digest:String,layer_diff_id:String,layer_digest:String) -> sled::Result<()> {
let tree = TreeWrapper::<JSONEncoder<ImageLayerLayerDigestToLayerDiffIDJSONValue>, JSONEncoder<ImageLayerLayerDigestToLayerDiffIDJSONValue>>::new(
db.open_tree("image_digest_layerdigest_to_layerdiffid_to")?,
);
let value = tree
.get(image_digest.clone());
let image_digest_json_value;
match value {
Ok(res) => {
match res {
Some(res1) =>{
match res1.decode() {
Some(mut res2) => {
res2.image_digest_layerdigest_to_layerdiffid.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDigestToLayerDiffIDJSONValue {
image_digest_layerdigest_to_layerdiffid: res2.image_digest_layerdigest_to_layerdiffid
};
}
_ => {
let mut image_digest_layerdigest_to_layerdiffid = HashMap::new();
image_digest_layerdigest_to_layerdiffid.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDigestToLayerDiffIDJSONValue {
image_digest_layerdigest_to_layerdiffid
};
}
}
},
_ => {
let mut image_digest_layerdigest_to_layerdiffid = HashMap::new();
image_digest_layerdigest_to_layerdiffid.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDigestToLayerDiffIDJSONValue {
image_digest_layerdigest_to_layerdiffid
};
}
}
},
Err(_) => {
let mut image_digest_layerdigest_to_layerdiffid = HashMap::new();
image_digest_layerdigest_to_layerdiffid.insert(layer_diff_id.clone(),layer_digest.clone());
image_digest_json_value = ImageLayerLayerDigestToLayerDiffIDJSONValue {
image_digest_layerdigest_to_layerdiffid
};
}
};
tree.insert(image_digest.clone(), &image_digest_json_value)?;
Ok(())
}