turingdb_helpers/traits.rs
1/// Ensures that a data structure is converted to bytes before it is sent over the wire
2pub trait TuringPacket<'tp> {
3 /// ### Converts a data structure into bytes in order to be sent over the wire
4 /// #### Usage
5 /// ```
6 /// use crate::TuringPacket;
7 ///
8 /// struct Foo;
9 ///
10 /// impl TuringPacket for Foo {
11 /// fn into_packet(value: T) -> &'tp [u8] {
12 /// value.as_bytes()
13 /// }
14 /// }
15 /// ```
16 fn into_packet<T>(value: T) -> &'tp [u8];
17}