Repository: pyfisch/cbor (rust)

Issue:
Broken roundtrip serialization
#54 (which attempted to fix #51 and #52) actually broke deserialization of Ipv4Addr (or, really, any other human-readability-dependant format) - `Deserializer` must have `is_human_readable` returning the same value as serializer.

Right now, if you try to serialize `Ipv4Addr`, it will serialize it as sequence of bytes, but will try to deserialize as a string, resulting in an error:

```
called `Result::unwrap()` on an `Err` value: ErrorImpl { code: Message("invalid type:sequence, expected a string"), offset: 0 }
```

Pull request description:
Fix roundtrip (de)serialization
Add failing test and fix #57 by setting Deserializer's `is_human_readable` to `false` to match `Serializer`.

Patch:
diff --git a/src/de.rs b/src/de.rs
index 5632b58..c1bfeb8 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -663,6 +663,11 @@ where
         }
     }
 
+    #[inline]
+    fn is_human_readable(&self) -> bool {
+        false
+    }
+
     forward_to_deserialize_any! {
         bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string unit
         unit_struct seq tuple tuple_struct map struct identifier ignored_any
diff --git a/src/ser.rs b/src/ser.rs
index f0d524e..5f20dbc 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -454,6 +454,7 @@ where
         self.serialize_struct(name, len)
     }
 
+    #[inline]
     fn is_human_readable(&self) -> bool {
         false
     }


Test patch:
diff --git a/tests/ser.rs b/tests/ser.rs
index a30c9a5..2014d72 100644
--- a/tests/ser.rs
+++ b/tests/ser.rs
@@ -100,4 +100,6 @@ fn test_ip_addr() {
     let vec = to_vec(&addr).unwrap();
     println!("{:?}", vec);
     assert_eq!(vec.len(), 5);
+    let test_addr: Ipv4Addr = from_slice(&vec).unwrap();
+    assert_eq!(addr, test_addr);
 }