[][src]Macro protobuf_codec::protobuf_message_encoder

macro_rules! protobuf_message_encoder {
    () => { ... };
    ($field:tt) => { ... };
    ($($field:tt),*) => { ... };
}

Macro for creating an instance of a message encoder.

Examples

use bytecodec::EncodeExt;
use protobuf_codec::field::num::{F1, F2};
use protobuf_codec::scalar::Int32Encoder;

// syntax = "proto3";
//
// message Pair {
//   int32 aaa = 1;
//   int32 bbb = 2;
// }

let mut encoder = protobuf_message_encoder![
    (F1, Int32Encoder::new()),
    (F2, Int32Encoder::new(), required)
];
assert_eq!(encoder.encode_into_bytes((1,2)).unwrap(), [8, 1, 16, 2]);