Marks a type which can be serialized to and from a binary encoding of either fixed or variable length.
| 3 | /// Marks a type which can be serialized to and from a binary encoding of either |
| 4 | /// fixed or variable length. |
| 5 | pub trait BinaryEncoding: Sized { |
| 6 | /// The binary type which is returned by serialization. Should either |
| 7 | /// be `[u8; N]` or `Vec<u8>`. |
| 8 | type Serialized; |
| 9 | |
| 10 | /// Serialize this data structure to its binary representation. |
| 11 | fn to_bytes(&self) -> Self::Serialized; |
| 12 | |
| 13 | /// Deserialize this data structure from a binary representation. |
| 14 | fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError<Self>>; |
| 15 | } |
| 16 | |
| 17 | /// Implements various binary encoding traits for both fixed or |
| 18 | /// variable-length encoded data structures. |
nothing calls this directly
no outgoing calls
no test coverage detected