1
// automatically generated by the FlatBuffers compiler, do not modify
2

            
3

            
4
// @generated
5

            
6
use core::mem;
7
use core::cmp::Ordering;
8

            
9
extern crate flatbuffers;
10
use self::flatbuffers::{EndianScalar, Follow};
11

            
12
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
13
pub const ENUM_MIN_PROGRAM_INPUT_TYPE: u8 = 0;
14
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
15
pub const ENUM_MAX_PROGRAM_INPUT_TYPE: u8 = 3;
16
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
17
#[allow(non_camel_case_types)]
18
pub const ENUM_VALUES_PROGRAM_INPUT_TYPE: [ProgramInputType; 4] = [
19
  ProgramInputType::Unknown,
20
  ProgramInputType::Public,
21
  ProgramInputType::Private,
22
  ProgramInputType::PublicProof,
23
];
24

            
25
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
26
#[repr(transparent)]
27
pub struct ProgramInputType(pub u8);
28
#[allow(non_upper_case_globals)]
29
impl ProgramInputType {
30
  pub const Unknown: Self = Self(0);
31
  pub const Public: Self = Self(1);
32
  pub const Private: Self = Self(2);
33
  pub const PublicProof: Self = Self(3);
34

            
35
  pub const ENUM_MIN: u8 = 0;
36
  pub const ENUM_MAX: u8 = 3;
37
  pub const ENUM_VALUES: &'static [Self] = &[
38
    Self::Unknown,
39
    Self::Public,
40
    Self::Private,
41
    Self::PublicProof,
42
  ];
43
  /// Returns the variant's name or "" if unknown.
44
  pub fn variant_name(self) -> Option<&'static str> {
45
    match self {
46
      Self::Unknown => Some("Unknown"),
47
      Self::Public => Some("Public"),
48
      Self::Private => Some("Private"),
49
      Self::PublicProof => Some("PublicProof"),
50
      _ => None,
51
    }
52
  }
53
}
54
impl core::fmt::Debug for ProgramInputType {
55
  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
56
    if let Some(name) = self.variant_name() {
57
      f.write_str(name)
58
    } else {
59
      f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
60
    }
61
  }
62
}
63
impl<'a> flatbuffers::Follow<'a> for ProgramInputType {
64
  type Inner = Self;
65
  #[inline]
66
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
67
    let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
68
    Self(b)
69
  }
70
}
71

            
72
impl flatbuffers::Push for ProgramInputType {
73
    type Output = ProgramInputType;
74
    #[inline]
75
    unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
76
        flatbuffers::emplace_scalar::<u8>(dst, self.0);
77
    }
78
}
79

            
80
impl flatbuffers::EndianScalar for ProgramInputType {
81
  type Scalar = u8;
82
  #[inline]
83
  fn to_little_endian(self) -> u8 {
84
    self.0.to_le()
85
  }
86
  #[inline]
87
  #[allow(clippy::wrong_self_convention)]
88
  fn from_little_endian(v: u8) -> Self {
89
    let b = u8::from_le(v);
90
    Self(b)
91
  }
92
}
93

            
94
impl<'a> flatbuffers::Verifiable for ProgramInputType {
95
  #[inline]
96
  fn run_verifier(
97
    v: &mut flatbuffers::Verifier, pos: usize
98
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
99
    use self::flatbuffers::Verifiable;
100
    u8::run_verifier(v, pos)
101
  }
102
}
103

            
104
impl flatbuffers::SimpleToVerifyInSlice for ProgramInputType {}
105
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
106
pub const ENUM_MIN_INPUT_TYPE: u8 = 0;
107
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
108
pub const ENUM_MAX_INPUT_TYPE: u8 = 8;
109
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
110
#[allow(non_camel_case_types)]
111
pub const ENUM_VALUES_INPUT_TYPE: [InputType; 7] = [
112
  InputType::Unknown,
113
  InputType::PublicData,
114
  InputType::PublicAccountData,
115
  InputType::PublicUrl,
116
  InputType::Private,
117
  InputType::PublicProof,
118
  InputType::PrivateLocal,
119
];
120

            
121
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
122
#[repr(transparent)]
123
pub struct InputType(pub u8);
124
#[allow(non_upper_case_globals)]
125
impl InputType {
126
  pub const Unknown: Self = Self(0);
127
  pub const PublicData: Self = Self(1);
128
  pub const PublicAccountData: Self = Self(3);
129
  pub const PublicUrl: Self = Self(4);
130
  pub const Private: Self = Self(5);
131
  pub const PublicProof: Self = Self(7);
132
  pub const PrivateLocal: Self = Self(8);
133

            
134
  pub const ENUM_MIN: u8 = 0;
135
  pub const ENUM_MAX: u8 = 8;
136
  pub const ENUM_VALUES: &'static [Self] = &[
137
    Self::Unknown,
138
    Self::PublicData,
139
    Self::PublicAccountData,
140
    Self::PublicUrl,
141
    Self::Private,
142
    Self::PublicProof,
143
    Self::PrivateLocal,
144
  ];
145
  /// Returns the variant's name or "" if unknown.
146
  pub fn variant_name(self) -> Option<&'static str> {
147
    match self {
148
      Self::Unknown => Some("Unknown"),
149
      Self::PublicData => Some("PublicData"),
150
      Self::PublicAccountData => Some("PublicAccountData"),
151
      Self::PublicUrl => Some("PublicUrl"),
152
      Self::Private => Some("Private"),
153
      Self::PublicProof => Some("PublicProof"),
154
      Self::PrivateLocal => Some("PrivateLocal"),
155
      _ => None,
156
    }
157
  }
158
}
159
impl core::fmt::Debug for InputType {
160
  fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
161
    if let Some(name) = self.variant_name() {
162
      f.write_str(name)
163
    } else {
164
      f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
165
    }
166
  }
167
}
168
impl<'a> flatbuffers::Follow<'a> for InputType {
169
  type Inner = Self;
170
  #[inline]
171
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
172
    let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
173
    Self(b)
174
  }
175
}
176

            
177
impl flatbuffers::Push for InputType {
178
    type Output = InputType;
179
    #[inline]
180
    unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
181
        flatbuffers::emplace_scalar::<u8>(dst, self.0);
182
    }
183
}
184

            
185
impl flatbuffers::EndianScalar for InputType {
186
  type Scalar = u8;
187
  #[inline]
188
  fn to_little_endian(self) -> u8 {
189
    self.0.to_le()
190
  }
191
  #[inline]
192
  #[allow(clippy::wrong_self_convention)]
193
  fn from_little_endian(v: u8) -> Self {
194
    let b = u8::from_le(v);
195
    Self(b)
196
  }
197
}
198

            
199
impl<'a> flatbuffers::Verifiable for InputType {
200
  #[inline]
201
  fn run_verifier(
202
    v: &mut flatbuffers::Verifier, pos: usize
203
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
204
    use self::flatbuffers::Verifiable;
205
    u8::run_verifier(v, pos)
206
  }
207
}
208

            
209
impl flatbuffers::SimpleToVerifyInSlice for InputType {}
210
pub enum InputOffset {}
211
#[derive(Copy, Clone, PartialEq)]
212

            
213
pub struct Input<'a> {
214
  pub _tab: flatbuffers::Table<'a>,
215
}
216

            
217
impl<'a> flatbuffers::Follow<'a> for Input<'a> {
218
  type Inner = Input<'a>;
219
  #[inline]
220
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
221
    Self { _tab: flatbuffers::Table::new(buf, loc) }
222
  }
223
}
224

            
225
impl<'a> Input<'a> {
226
  pub const VT_INPUT_TYPE: flatbuffers::VOffsetT = 4;
227
  pub const VT_DATA: flatbuffers::VOffsetT = 6;
228

            
229
  #[inline]
230
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
231
    Input { _tab: table }
232
  }
233
  #[allow(unused_mut)]
234
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
235
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
236
    args: &'args InputArgs<'args>
237
  ) -> flatbuffers::WIPOffset<Input<'bldr>> {
238
    let mut builder = InputBuilder::new(_fbb);
239
    if let Some(x) = args.data { builder.add_data(x); }
240
    builder.add_input_type(args.input_type);
241
    builder.finish()
242
  }
243

            
244
  pub fn unpack(&self) -> InputT {
245
    let input_type = self.input_type();
246
    let data = self.data().map(|x| {
247
      x.into_iter().collect()
248
    });
249
    InputT {
250
      input_type,
251
      data,
252
    }
253
  }
254

            
255
  #[inline]
256
  pub fn input_type(&self) -> InputType {
257
    // Safety:
258
    // Created from valid Table for this object
259
    // which contains a valid value in this slot
260
    unsafe { self._tab.get::<InputType>(Input::VT_INPUT_TYPE, Some(InputType::PublicData)).unwrap()}
261
  }
262
  #[inline]
263
  pub fn data(&self) -> Option<flatbuffers::Vector<'a, u8>> {
264
    // Safety:
265
    // Created from valid Table for this object
266
    // which contains a valid value in this slot
267
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Input::VT_DATA, None)}
268
  }
269
}
270

            
271
impl flatbuffers::Verifiable for Input<'_> {
272
  #[inline]
273
  fn run_verifier(
274
    v: &mut flatbuffers::Verifier, pos: usize
275
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
276
    use self::flatbuffers::Verifiable;
277
    v.visit_table(pos)?
278
     .visit_field::<InputType>("input_type", Self::VT_INPUT_TYPE, false)?
279
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("data", Self::VT_DATA, false)?
280
     .finish();
281
    Ok(())
282
  }
283
}
284
pub struct InputArgs<'a> {
285
    pub input_type: InputType,
286
    pub data: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
287
}
288
impl<'a> Default for InputArgs<'a> {
289
  #[inline]
290
  fn default() -> Self {
291
    InputArgs {
292
      input_type: InputType::PublicData,
293
      data: None,
294
    }
295
  }
296
}
297

            
298
pub struct InputBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
299
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
300
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
301
}
302
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> InputBuilder<'a, 'b, A> {
303
  #[inline]
304
  pub fn add_input_type(&mut self, input_type: InputType) {
305
    self.fbb_.push_slot::<InputType>(Input::VT_INPUT_TYPE, input_type, InputType::PublicData);
306
  }
307
  #[inline]
308
  pub fn add_data(&mut self, data: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
309
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Input::VT_DATA, data);
310
  }
311
  #[inline]
312
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> InputBuilder<'a, 'b, A> {
313
    let start = _fbb.start_table();
314
    InputBuilder {
315
      fbb_: _fbb,
316
      start_: start,
317
    }
318
  }
319
  #[inline]
320
  pub fn finish(self) -> flatbuffers::WIPOffset<Input<'a>> {
321
    let o = self.fbb_.end_table(self.start_);
322
    flatbuffers::WIPOffset::new(o.value())
323
  }
324
}
325

            
326
impl core::fmt::Debug for Input<'_> {
327
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
328
    let mut ds = f.debug_struct("Input");
329
      ds.field("input_type", &self.input_type());
330
      ds.field("data", &self.data());
331
      ds.finish()
332
  }
333
}
334
#[non_exhaustive]
335
#[derive(Debug, Clone, PartialEq)]
336
pub struct InputT {
337
  pub input_type: InputType,
338
  pub data: Option<Vec<u8>>,
339
}
340
impl Default for InputT {
341
  fn default() -> Self {
342
    Self {
343
      input_type: InputType::PublicData,
344
      data: None,
345
    }
346
  }
347
}
348
impl InputT {
349
  pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
350
    &self,
351
    _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
352
  ) -> flatbuffers::WIPOffset<Input<'b>> {
353
    let input_type = self.input_type;
354
    let data = self.data.as_ref().map(|x|{
355
      _fbb.create_vector(x)
356
    });
357
    Input::create(_fbb, &InputArgs{
358
      input_type,
359
      data,
360
    })
361
  }
362
}