+impl Writeable for InputDescriptors {
+ fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+ match self {
+ &InputDescriptors::RevokedOfferedHTLC => {
+ writer.write_all(&[0; 1])?;
+ },
+ &InputDescriptors::RevokedReceivedHTLC => {
+ writer.write_all(&[1; 1])?;
+ },
+ &InputDescriptors::OfferedHTLC => {
+ writer.write_all(&[2; 1])?;
+ },
+ &InputDescriptors::ReceivedHTLC => {
+ writer.write_all(&[3; 1])?;
+ }
+ &InputDescriptors::RevokedOutput => {
+ writer.write_all(&[4; 1])?;
+ }
+ }
+ Ok(())
+ }
+}
+
+impl Readable for InputDescriptors {
+ fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+ let input_descriptor = match <u8 as Readable>::read(reader)? {
+ 0 => {
+ InputDescriptors::RevokedOfferedHTLC
+ },
+ 1 => {
+ InputDescriptors::RevokedReceivedHTLC
+ },
+ 2 => {
+ InputDescriptors::OfferedHTLC
+ },
+ 3 => {
+ InputDescriptors::ReceivedHTLC
+ },
+ 4 => {
+ InputDescriptors::RevokedOutput
+ }
+ _ => return Err(DecodeError::InvalidValue),
+ };
+ Ok(input_descriptor)
+ }
+}
+