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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/// Provides encoder input format options.
/// 
/// This is a list of all binary formats supported by the encoder.
#[derive(Debug)]
pub enum EncoderLit<'a> {
    /// Represents `binary` format of wire type `2`.
    Bytes(&'a Vec<u8>),

    /// Represents `bool` format of wire type `0`.
    Bool(&'a bool),

    /// Represents `bool` format of wire type `2` for packed repeated fields.
    BoolVec(&'a Vec<bool>),

    /// Represents `int32` format of wire type `0`.
    Int32(&'a i32),

    /// Represents `int32` format of wire type `0` for packed repeated fields.
    Int32Vec(&'a Vec<i32>),

    /// Represents `int64` format of wire type `0`.
    Int64(&'a i64),

    /// Represents `int64` format of wire type `0` for packed repeated fields.
    Int64Vec(&'a Vec<i64>),

    /// Represents `uint32` format of wire type `0`.
    UInt32(&'a u32),

    /// Represents `uint32` format of wire type `0` for packed repeated fields.
    UInt32Vec(&'a Vec<u32>),

    /// Represents `uint64` format of wire type `0`.
    UInt64(&'a u64),

    /// Represents `uint64` format of wire type `0` for packed repeated fields.
    UInt64Vec(&'a Vec<u64>),

    /// Represents `float` format of wire type `5`.
    Float(&'a f32),

    /// Represents `float` format of wire type `5` for packed repeated fields.
    FloatVec(&'a Vec<f32>),

    /// Represents `uint32` format of wire type `1`.
    Double(&'a f64),

    /// Represents `double` format of wire type `1` for packed repeated fields.
    DoubleVec(&'a Vec<f64>),

    /// Represents `sint32` format of wire type `0`. Use it when the value is
    /// likely to be negative.
    SInt32(&'a i32),

    /// Represents `sint32` format of wire type `0` for packed repeated fields.
    /// Use it when the values are likely to be negative.
    SInt32Vec(&'a Vec<i32>),

    /// Represents `sint64` format of wire type `0`. Use it when the value is
    /// likely to be negative.
    SInt64(&'a i64),

    /// Represents `sint64` format of wire type `0` for packed repeated fields.
    /// Use it when the values are likely to be negative.
    SInt64Vec(&'a Vec<i64>),

    /// Represents `fixed32` format of wire type `5`.
    Fixed32(&'a u32),

    /// Represents `fixed32` format of wire type `5` for packed repeated fields.
    Fixed32Vec(&'a Vec<u32>),

    /// Represents `fixed64` format of wire type `1`.
    Fixed64(&'a u64),

    /// Represents `fixed64` format of wire type `1` for packed repeated fields.
    Fixed64Vec(&'a Vec<u64>),

    /// Represents `sfixed32` format of wire type `5`.
    SFixed32(&'a i32),

    /// Represents `sfixed32` format of wire type `5` for packed repeated
    /// fields.
    SFixed32Vec(&'a Vec<i32>),

    /// Represents `sfixed64` format of wire type `1`.
    SFixed64(&'a i64),

    /// Represents `sfixed64` format of wire type `1` for packed repeated
    /// fields.
    SFixed64Vec(&'a Vec<i64>),
}

impl<'a> From<&'a bool> for EncoderLit<'a> {
    fn from(v: &'a bool) -> Self {
        Self::Bool(v)
    }
}

impl<'a> From<&'a Vec<bool>> for EncoderLit<'a> {
    fn from(v: &'a Vec<bool>) -> Self {
        Self::BoolVec(v)
    }
}

impl<'a> From<&'a i32> for EncoderLit<'a> {
    fn from(v: &'a i32) -> Self {
        Self::Int32(v)
    }
}

impl<'a> From<&'a Vec<i32>> for EncoderLit<'a> {
    fn from(v: &'a Vec<i32>) -> Self {
        Self::Int32Vec(v)
    }
}

impl<'a> From<&'a i64> for EncoderLit<'a> {
    fn from(v: &'a i64) -> Self {
        Self::Int64(v)
    }
}

impl<'a> From<&'a Vec<i64>> for EncoderLit<'a> {
    fn from(v: &'a Vec<i64>) -> Self {
        Self::Int64Vec(v)
    }
}

impl<'a> From<&'a u32> for EncoderLit<'a> {
    fn from(v: &'a u32) -> Self {
        Self::UInt32(v)
    }
}

impl<'a> From<&'a Vec<u32>> for EncoderLit<'a> {
    fn from(v: &'a Vec<u32>) -> Self {
        Self::UInt32Vec(v)
    }
}

impl<'a> From<&'a u64> for EncoderLit<'a> {
    fn from(v: &'a u64) -> Self {
        Self::UInt64(v)
    }
}

impl<'a> From<&'a Vec<u64>> for EncoderLit<'a> {
    fn from(v: &'a Vec<u64>) -> Self {
        Self::UInt64Vec(v)
    }
}

impl<'a> From<&'a f32> for EncoderLit<'a> {
    fn from(v: &'a f32) -> Self {
        Self::Float(v)
    }
}

impl<'a> From<&'a Vec<f32>> for EncoderLit<'a> {
    fn from(v: &'a Vec<f32>) -> Self {
        Self::FloatVec(v)
    }
}

impl<'a> From<&'a f64> for EncoderLit<'a> {
    fn from(v: &'a f64) -> Self {
        Self::Double(v)
    }
}

impl<'a> From<&'a Vec<f64>> for EncoderLit<'a> {
    fn from(v: &'a Vec<f64>) -> Self {
        Self::DoubleVec(v)
    }
}

impl<'a> From<&'a Vec<u8>> for EncoderLit<'a> {
    fn from(v: &'a Vec<u8>) -> Self {
        Self::Bytes(v)
    }
}