diff --git a/src/storage/file.rs b/src/storage/file.rs index 0d0df446..bfa147af 100644 --- a/src/storage/file.rs +++ b/src/storage/file.rs @@ -11,6 +11,7 @@ pub enum FileHeaderSpec { Float, Text, Key { name: String, value_type: Box }, + Map { keys: Vec }, Array { allowed_types: Box> }, } @@ -23,6 +24,7 @@ pub enum FileHeaderData { Float(f64), Text(String), Key { name: String, value: Box }, + Map { keys: Vec }, Array { values: Box> }, } @@ -44,6 +46,9 @@ impl Display for FileHeaderSpec { &FileHeaderSpec::Key{name: ref n, value_type: ref vt} => { write!(fmt, "Key({:?}) -> {:?}", n, vt) } + &FileHeaderSpec::Map{keys: ref ks} => { + write!(fmt, "Map -> {:?}", ks) + } &FileHeaderSpec::Array{allowed_types: ref at} => { write!(fmt, "Array({:?})", at) } @@ -127,6 +132,18 @@ pub fn match_header_spec<'a>(spec: &'a FileHeaderSpec, data: &'a FileHeaderData) return match_header_spec(&*vtype, &*val); } + ( + &FileHeaderSpec::Map{keys: ref sks}, + &FileHeaderData::Map{keys: ref dks} + ) => { + for (s, d) in sks.iter().zip(dks.iter()) { + let res = match_header_spec(s, d); + if res.is_some() { + return res; + } + } + } + ( &FileHeaderSpec::Array{allowed_types: ref vtypes}, &FileHeaderData::Array{values: ref vs}