-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmacros.rs
More file actions
26 lines (25 loc) · 710 Bytes
/
macros.rs
File metadata and controls
26 lines (25 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
macro_rules! impl_encode_without_result {
($i:path, $m:ident) => {
impl $i {
pub fn encode(&self) -> bytes::BytesMut {
let mut encoder = crate::encode::Encoder::default();
encoder.$m(self);
encoder.bytes
}
}
};
}
macro_rules! impl_encode {
($i:path, $m:ident) => {
impl_encode!($i, $m, encode);
};
($i:path, $m:ident, $n:ident) => {
impl $i {
pub fn $n(&self) -> crate::EncodeResult<bytes::BytesMut> {
let mut encoder = crate::encode::Encoder::default();
encoder.$m(self)?;
Ok(encoder.bytes)
}
}
};
}