+impl Writeable for UpdateStatus {
+ fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+ // We only care about writing out the current state as it was announced, ie only either
+ // Enabled or Disabled. In the case of DisabledStaged, we most recently announced the
+ // channel as enabled, so we write 0. For EnabledStaged, we similarly write a 1.
+ match self {
+ UpdateStatus::Enabled => 0u8.write(writer)?,
+ UpdateStatus::DisabledStaged => 0u8.write(writer)?,
+ UpdateStatus::EnabledStaged => 1u8.write(writer)?,
+ UpdateStatus::Disabled => 1u8.write(writer)?,
+ }
+ Ok(())
+ }
+}
+
+impl Readable for UpdateStatus {
+ fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+ Ok(match <u8 as Readable>::read(reader)? {
+ 0 => UpdateStatus::Enabled,
+ 1 => UpdateStatus::Disabled,
+ _ => return Err(DecodeError::InvalidValue),
+ })
+ }
+}
+