summaryrefslogtreecommitdiff
path: root/src/definitions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/definitions.rs')
-rw-r--r--src/definitions.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/definitions.rs b/src/definitions.rs
index 3b07eda..20afe38 100644
--- a/src/definitions.rs
+++ b/src/definitions.rs
@@ -2,6 +2,8 @@ use serde_yaml;
use types::{NamedValue, Value};
+use std::collections::HashSet;
+
#[derive(Debug, Deserialize)]
pub struct RawECURequest {
sendto: u16,
@@ -108,7 +110,12 @@ impl RawECUEntry {
return None;
}
+ let mut used_locations: HashSet<usize> = HashSet::new();
+
for entry in &self.response.values {
+ for i in entry.offset..(entry.offset + entry.length) {
+ used_locations.insert(i);
+ }
if let Some(ref kind) = entry.kind {
let value: Value = match kind.as_ref() {
"unsigned" => match entry.length {
@@ -161,6 +168,17 @@ impl RawECUEntry {
}
}
+ for i in 0..payload.len() {
+ if !used_locations.contains(&i) {
+ let name = {
+ let mut n = self.name.clone();
+ n.push_str(&format!(".unused_{}", i));
+ n
+ };
+ ret.push(NamedValue::new(&name, Some(Value::from(payload[i]))));
+ }
+ }
+
Some(ret)
}
}