diff --git a/utils/core/src/serde/mod.rs b/utils/core/src/serde/mod.rs index b79301ad4..8ee06482a 100644 --- a/utils/core/src/serde/mod.rs +++ b/utils/core/src/serde/mod.rs @@ -188,6 +188,27 @@ impl Serializable for [T; C] { } } +impl Serializable for Vec { + fn write_into(&self, target: &mut W) { + target.write_usize(self.len()); + target.write_many(self); + } +} + +impl Serializable for BTreeMap { + fn write_into(&self, target: &mut W) { + target.write_usize(self.len()); + target.write_many(self); + } +} + +impl Serializable for BTreeSet { + fn write_into(&self, target: &mut W) { + target.write_usize(self.len()); + target.write_many(self); + } +} + // DESERIALIZABLE // ================================================================================================ @@ -378,3 +399,26 @@ impl Deserializable for [T; C] { Ok(res) } } + +impl Deserializable for Vec { + fn read_from(source: &mut R) -> Result { + let len = source.read_usize()?; + source.read_many(len) + } +} + +impl Deserializable for BTreeMap { + fn read_from(source: &mut R) -> Result { + let len = source.read_usize()?; + let data = source.read_many(len)?; + Ok(BTreeMap::from_iter(data)) + } +} + +impl Deserializable for BTreeSet { + fn read_from(source: &mut R) -> Result { + let len = source.read_usize()?; + let data = source.read_many(len)?; + Ok(BTreeSet::from_iter(data)) + } +}