diff --git a/utils/core/src/serde/mod.rs b/utils/core/src/serde/mod.rs index d24265f1b..471aa96c7 100644 --- a/utils/core/src/serde/mod.rs +++ b/utils/core/src/serde/mod.rs @@ -53,6 +53,90 @@ impl Serializable for () { fn write_into(&self, _target: &mut W) {} } +impl Serializable for (T1,) +where + T1: Serializable, +{ + fn write_into(&self, target: &mut W) { + self.0.write_into(target); + } +} + +impl Serializable for (T1, T2) +where + T1: Serializable, + T2: Serializable, +{ + fn write_into(&self, target: &mut W) { + self.0.write_into(target); + self.1.write_into(target); + } +} + +impl Serializable for (T1, T2, T3) +where + T1: Serializable, + T2: Serializable, + T3: Serializable, +{ + fn write_into(&self, target: &mut W) { + self.0.write_into(target); + self.1.write_into(target); + self.2.write_into(target); + } +} + +impl Serializable for (T1, T2, T3, T4) +where + T1: Serializable, + T2: Serializable, + T3: Serializable, + T4: Serializable, +{ + fn write_into(&self, target: &mut W) { + self.0.write_into(target); + self.1.write_into(target); + self.2.write_into(target); + self.3.write_into(target); + } +} + +impl Serializable for (T1, T2, T3, T4, T5) +where + T1: Serializable, + T2: Serializable, + T3: Serializable, + T4: Serializable, + T5: Serializable, +{ + fn write_into(&self, target: &mut W) { + self.0.write_into(target); + self.1.write_into(target); + self.2.write_into(target); + self.3.write_into(target); + self.4.write_into(target); + } +} + +impl Serializable for (T1, T2, T3, T4, T5, T6) +where + T1: Serializable, + T2: Serializable, + T3: Serializable, + T4: Serializable, + T5: Serializable, + T6: Serializable, +{ + fn write_into(&self, target: &mut W) { + self.0.write_into(target); + self.1.write_into(target); + self.2.write_into(target); + self.3.write_into(target); + self.4.write_into(target); + self.5.write_into(target); + } +} + impl Serializable for u8 { fn write_into(&self, target: &mut W) { target.write_u8(*self); @@ -217,6 +301,96 @@ impl Deserializable for () { } } +impl Deserializable for (T1,) +where + T1: Deserializable, +{ + fn read_from(source: &mut R) -> Result { + let v1 = T1::read_from(source)?; + Ok((v1,)) + } +} + +impl Deserializable for (T1, T2) +where + T1: Deserializable, + T2: Deserializable, +{ + fn read_from(source: &mut R) -> Result { + let v1 = T1::read_from(source)?; + let v2 = T2::read_from(source)?; + Ok((v1, v2)) + } +} + +impl Deserializable for (T1, T2, T3) +where + T1: Deserializable, + T2: Deserializable, + T3: Deserializable, +{ + fn read_from(source: &mut R) -> Result { + let v1 = T1::read_from(source)?; + let v2 = T2::read_from(source)?; + let v3 = T3::read_from(source)?; + Ok((v1, v2, v3)) + } +} + +impl Deserializable for (T1, T2, T3, T4) +where + T1: Deserializable, + T2: Deserializable, + T3: Deserializable, + T4: Deserializable, +{ + fn read_from(source: &mut R) -> Result { + let v1 = T1::read_from(source)?; + let v2 = T2::read_from(source)?; + let v3 = T3::read_from(source)?; + let v4 = T4::read_from(source)?; + Ok((v1, v2, v3, v4)) + } +} + +impl Deserializable for (T1, T2, T3, T4, T5) +where + T1: Deserializable, + T2: Deserializable, + T3: Deserializable, + T4: Deserializable, + T5: Deserializable, +{ + fn read_from(source: &mut R) -> Result { + let v1 = T1::read_from(source)?; + let v2 = T2::read_from(source)?; + let v3 = T3::read_from(source)?; + let v4 = T4::read_from(source)?; + let v5 = T5::read_from(source)?; + Ok((v1, v2, v3, v4, v5)) + } +} + +impl Deserializable for (T1, T2, T3, T4, T5, T6) +where + T1: Deserializable, + T2: Deserializable, + T3: Deserializable, + T4: Deserializable, + T5: Deserializable, + T6: Deserializable, +{ + fn read_from(source: &mut R) -> Result { + let v1 = T1::read_from(source)?; + let v2 = T2::read_from(source)?; + let v3 = T3::read_from(source)?; + let v4 = T4::read_from(source)?; + let v5 = T5::read_from(source)?; + let v6 = T6::read_from(source)?; + Ok((v1, v2, v3, v4, v5, v6)) + } +} + impl Deserializable for u8 { fn read_from(source: &mut R) -> Result { source.read_u8()