protobuf/
fixed.rs

1/// Fixed size integers.
2pub(crate) trait ProtobufFixed {
3    /// Size of this fixed type in bytes.
4    const LEN: u32;
5}
6
7impl ProtobufFixed for u32 {
8    const LEN: u32 = 4;
9}
10
11impl ProtobufFixed for i32 {
12    const LEN: u32 = 4;
13}
14
15impl ProtobufFixed for u64 {
16    const LEN: u32 = 8;
17}
18
19impl ProtobufFixed for i64 {
20    const LEN: u32 = 8;
21}
22
23impl ProtobufFixed for f32 {
24    const LEN: u32 = 4;
25}
26
27impl ProtobufFixed for f64 {
28    const LEN: u32 = 8;
29}
30
31/// Technically `bool` is not fixed, but it can be considered as fixed
32/// for the purpose of encoding.
33impl ProtobufFixed for bool {
34    const LEN: u32 = 1;
35}