Derive Macro binary_util::BinaryStream
source · #[derive(BinaryStream)]
Expand description
Provides a derive macro that implements ::binary_util::interfaces::Reader<T>
and ::binary_util::interfaces::Writer<T>
.
DEPRECATED.
This is a legacy proc-macro that is used to generate a BufferStream.
It provides an easy way to implement the Streamable
trait.
⚠️ This proc-macro has been deprecated since
0.3.0
in favor ofbinary_util::interfaces::Reader
andbinary_util::interfaces::Writer
and will be removed in0.4.0
.
This proc-macro automatically implements the Streamable
trait for the struct or enum it is applied to.
Example:
ⓘ
use binary_util::BinaryStream;
#[derive(BinaryStream)]
struct Test {
a: u8,
b: u16
}
fn main() {
let test = Test { a: 0, b: 0 };
test.parse().unwrap();
}
Please note that this proc-macro does not support unit structs or named enum variants, meaning a code sample like the following will not work:
use binary_util::BinaryStream;
// Error: Unit structs are not supported.
#[derive(BinaryStream)]
struct Test;
// Error: Invalid variant.
#[derive(BinaryStream)]
enum TestEnum {
B(Test)
}
Warning: This module is deprecated and will be removed in v0.4.0.