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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! otoPr - Obvious Rust Protobuf Library
//!
//! This library focuses on API design and performance.

pub(crate) extern crate self as otopr;

pub use otopr_derive::*;

#[macro_use]
mod macros {
    #[macro_export]
    macro_rules! seal {
        ($(for$(<$($id:ident$(: $bound:path)?),+ $(,)?>)? $ty:ty),+ $(,)?) => {
            $(
                impl$(<$($id$(: $bound)?),*>)? crate::traits::private::Sealed for $ty {}
            )*
        };
    }
}

pub mod prelude;

pub mod traits;

pub mod decoding;
pub mod encoding;

mod repeated;
pub use repeated::*;

mod varint;
pub use varint::VarInt;

mod map;
pub use map::Map;

#[cfg(test)]
pub mod tests;

mod impls;
pub mod wire_types;

#[doc(hidden)]
pub mod __private;

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
#[repr(transparent)]
pub struct Packed<T>(T);

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
#[repr(transparent)]
pub struct Signed<T: traits::Signable>(T::Storage);

impl<T: traits::Signable> Signed<T> {
    /// Creates a new instance of `Signed` by encoding using zigzag.
    pub fn new(t: T::From) -> Self {
        Self(T::zigzag_encode(t))
    }
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
#[repr(transparent)]
pub struct Fixed32(u32);

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
#[repr(transparent)]
pub struct Fixed64(u64);

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
#[repr(transparent)]
pub struct Message<T>(T);

impl<T> Message<T> {
    pub fn into_inner(self) -> T {
        self.0
    }
}

#[allow(non_camel_case_types)]
pub mod types {
    use crate::*;

    pub type sfixed64 = Signed<Fixed32>;
    pub type sfixed32 = Signed<Fixed64>;
}