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

            
3

            
4
// @generated
5

            
6
use crate::status_v1_generated::*;
7
use crate::input_type_generated::*;
8
use crate::execution_request_v1_generated::*;
9
use crate::deploy_v1_generated::*;
10
use crate::claim_v1_generated::*;
11
use core::mem;
12
use core::cmp::Ordering;
13

            
14
extern crate flatbuffers;
15
use self::flatbuffers::{EndianScalar, Follow};
16

            
17
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
18
pub const ENUM_MIN_CHANNEL_INSTRUCTION_IX_TYPE: u8 = 0;
19
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
20
pub const ENUM_MAX_CHANNEL_INSTRUCTION_IX_TYPE: u8 = 3;
21
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
22
#[allow(non_camel_case_types)]
23
pub const ENUM_VALUES_CHANNEL_INSTRUCTION_IX_TYPE: [ChannelInstructionIxType; 4] = [
24
  ChannelInstructionIxType::ExecuteV1,
25
  ChannelInstructionIxType::StatusV1,
26
  ChannelInstructionIxType::DeployV1,
27
  ChannelInstructionIxType::ClaimV1,
28
];
29

            
30
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
31
#[repr(transparent)]
32
pub struct ChannelInstructionIxType(pub u8);
33
#[allow(non_upper_case_globals)]
34
impl ChannelInstructionIxType {
35
  pub const ExecuteV1: Self = Self(0);
36
  pub const StatusV1: Self = Self(1);
37
  pub const DeployV1: Self = Self(2);
38
  pub const ClaimV1: Self = Self(3);
39

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

            
77
impl flatbuffers::Push for ChannelInstructionIxType {
78
    type Output = ChannelInstructionIxType;
79
    #[inline]
80
    unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
81
        flatbuffers::emplace_scalar::<u8>(dst, self.0);
82
    }
83
}
84

            
85
impl flatbuffers::EndianScalar for ChannelInstructionIxType {
86
  type Scalar = u8;
87
  #[inline]
88
  fn to_little_endian(self) -> u8 {
89
    self.0.to_le()
90
  }
91
  #[inline]
92
  #[allow(clippy::wrong_self_convention)]
93
  fn from_little_endian(v: u8) -> Self {
94
    let b = u8::from_le(v);
95
    Self(b)
96
  }
97
}
98

            
99
impl<'a> flatbuffers::Verifiable for ChannelInstructionIxType {
100
  #[inline]
101
  fn run_verifier(
102
    v: &mut flatbuffers::Verifier, pos: usize
103
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
104
    use self::flatbuffers::Verifiable;
105
    u8::run_verifier(v, pos)
106
  }
107
}
108

            
109
impl flatbuffers::SimpleToVerifyInSlice for ChannelInstructionIxType {}
110
pub enum ChannelInstructionOffset {}
111
#[derive(Copy, Clone, PartialEq)]
112

            
113
pub struct ChannelInstruction<'a> {
114
  pub _tab: flatbuffers::Table<'a>,
115
}
116

            
117
impl<'a> flatbuffers::Follow<'a> for ChannelInstruction<'a> {
118
  type Inner = ChannelInstruction<'a>;
119
  #[inline]
120
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
121
    Self { _tab: flatbuffers::Table::new(buf, loc) }
122
  }
123
}
124

            
125
impl<'a> ChannelInstruction<'a> {
126
  pub const VT_IX_TYPE: flatbuffers::VOffsetT = 4;
127
  pub const VT_EXECUTE_V1: flatbuffers::VOffsetT = 6;
128
  pub const VT_STATUS_V1: flatbuffers::VOffsetT = 8;
129
  pub const VT_DEPLOY_V1: flatbuffers::VOffsetT = 10;
130
  pub const VT_CLAIM_V1: flatbuffers::VOffsetT = 12;
131

            
132
  #[inline]
133
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
134
    ChannelInstruction { _tab: table }
135
  }
136
  #[allow(unused_mut)]
137
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
138
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
139
    args: &'args ChannelInstructionArgs<'args>
140
  ) -> flatbuffers::WIPOffset<ChannelInstruction<'bldr>> {
141
    let mut builder = ChannelInstructionBuilder::new(_fbb);
142
    if let Some(x) = args.claim_v1 { builder.add_claim_v1(x); }
143
    if let Some(x) = args.deploy_v1 { builder.add_deploy_v1(x); }
144
    if let Some(x) = args.status_v1 { builder.add_status_v1(x); }
145
    if let Some(x) = args.execute_v1 { builder.add_execute_v1(x); }
146
    builder.add_ix_type(args.ix_type);
147
    builder.finish()
148
  }
149

            
150
  pub fn unpack(&self) -> ChannelInstructionT {
151
    let ix_type = self.ix_type();
152
    let execute_v1 = self.execute_v1().map(|x| {
153
      x.into_iter().collect()
154
    });
155
    let status_v1 = self.status_v1().map(|x| {
156
      x.into_iter().collect()
157
    });
158
    let deploy_v1 = self.deploy_v1().map(|x| {
159
      x.into_iter().collect()
160
    });
161
    let claim_v1 = self.claim_v1().map(|x| {
162
      x.into_iter().collect()
163
    });
164
    ChannelInstructionT {
165
      ix_type,
166
      execute_v1,
167
      status_v1,
168
      deploy_v1,
169
      claim_v1,
170
    }
171
  }
172

            
173
  #[inline]
174
  pub fn ix_type(&self) -> ChannelInstructionIxType {
175
    // Safety:
176
    // Created from valid Table for this object
177
    // which contains a valid value in this slot
178
    unsafe { self._tab.get::<ChannelInstructionIxType>(ChannelInstruction::VT_IX_TYPE, Some(ChannelInstructionIxType::ExecuteV1)).unwrap()}
179
  }
180
  #[inline]
181
  pub fn execute_v1(&self) -> Option<flatbuffers::Vector<'a, u8>> {
182
    // Safety:
183
    // Created from valid Table for this object
184
    // which contains a valid value in this slot
185
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(ChannelInstruction::VT_EXECUTE_V1, None)}
186
  }
187
  pub fn execute_v1_nested_flatbuffer(&'a self) -> Option<ExecutionRequestV1<'a>> {
188
    self.execute_v1().map(|data| {
189
      use flatbuffers::Follow;
190
      // Safety:
191
      // Created from a valid Table for this object
192
      // Which contains a valid flatbuffer in this slot
193
      unsafe { <flatbuffers::ForwardsUOffset<ExecutionRequestV1<'a>>>::follow(data.bytes(), 0) }
194
    })
195
  }
196
  #[inline]
197
  pub fn status_v1(&self) -> Option<flatbuffers::Vector<'a, u8>> {
198
    // Safety:
199
    // Created from valid Table for this object
200
    // which contains a valid value in this slot
201
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(ChannelInstruction::VT_STATUS_V1, None)}
202
  }
203
  pub fn status_v1_nested_flatbuffer(&'a self) -> Option<StatusV1<'a>> {
204
    self.status_v1().map(|data| {
205
      use flatbuffers::Follow;
206
      // Safety:
207
      // Created from a valid Table for this object
208
      // Which contains a valid flatbuffer in this slot
209
      unsafe { <flatbuffers::ForwardsUOffset<StatusV1<'a>>>::follow(data.bytes(), 0) }
210
    })
211
  }
212
  #[inline]
213
  pub fn deploy_v1(&self) -> Option<flatbuffers::Vector<'a, u8>> {
214
    // Safety:
215
    // Created from valid Table for this object
216
    // which contains a valid value in this slot
217
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(ChannelInstruction::VT_DEPLOY_V1, None)}
218
  }
219
  pub fn deploy_v1_nested_flatbuffer(&'a self) -> Option<DeployV1<'a>> {
220
    self.deploy_v1().map(|data| {
221
      use flatbuffers::Follow;
222
      // Safety:
223
      // Created from a valid Table for this object
224
      // Which contains a valid flatbuffer in this slot
225
      unsafe { <flatbuffers::ForwardsUOffset<DeployV1<'a>>>::follow(data.bytes(), 0) }
226
    })
227
  }
228
  #[inline]
229
  pub fn claim_v1(&self) -> Option<flatbuffers::Vector<'a, u8>> {
230
    // Safety:
231
    // Created from valid Table for this object
232
    // which contains a valid value in this slot
233
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(ChannelInstruction::VT_CLAIM_V1, None)}
234
  }
235
  pub fn claim_v1_nested_flatbuffer(&'a self) -> Option<ClaimV1<'a>> {
236
    self.claim_v1().map(|data| {
237
      use flatbuffers::Follow;
238
      // Safety:
239
      // Created from a valid Table for this object
240
      // Which contains a valid flatbuffer in this slot
241
      unsafe { <flatbuffers::ForwardsUOffset<ClaimV1<'a>>>::follow(data.bytes(), 0) }
242
    })
243
  }
244
}
245

            
246
impl flatbuffers::Verifiable for ChannelInstruction<'_> {
247
  #[inline]
248
  fn run_verifier(
249
    v: &mut flatbuffers::Verifier, pos: usize
250
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
251
    use self::flatbuffers::Verifiable;
252
    v.visit_table(pos)?
253
     .visit_field::<ChannelInstructionIxType>("ix_type", Self::VT_IX_TYPE, false)?
254
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("execute_v1", Self::VT_EXECUTE_V1, false)?
255
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("status_v1", Self::VT_STATUS_V1, false)?
256
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("deploy_v1", Self::VT_DEPLOY_V1, false)?
257
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("claim_v1", Self::VT_CLAIM_V1, false)?
258
     .finish();
259
    Ok(())
260
  }
261
}
262
pub struct ChannelInstructionArgs<'a> {
263
    pub ix_type: ChannelInstructionIxType,
264
    pub execute_v1: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
265
    pub status_v1: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
266
    pub deploy_v1: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
267
    pub claim_v1: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
268
}
269
impl<'a> Default for ChannelInstructionArgs<'a> {
270
  #[inline]
271
  fn default() -> Self {
272
    ChannelInstructionArgs {
273
      ix_type: ChannelInstructionIxType::ExecuteV1,
274
      execute_v1: None,
275
      status_v1: None,
276
      deploy_v1: None,
277
      claim_v1: None,
278
    }
279
  }
280
}
281

            
282
pub struct ChannelInstructionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
283
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
284
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
285
}
286
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ChannelInstructionBuilder<'a, 'b, A> {
287
  #[inline]
288
  pub fn add_ix_type(&mut self, ix_type: ChannelInstructionIxType) {
289
    self.fbb_.push_slot::<ChannelInstructionIxType>(ChannelInstruction::VT_IX_TYPE, ix_type, ChannelInstructionIxType::ExecuteV1);
290
  }
291
  #[inline]
292
  pub fn add_execute_v1(&mut self, execute_v1: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
293
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ChannelInstruction::VT_EXECUTE_V1, execute_v1);
294
  }
295
  #[inline]
296
  pub fn add_status_v1(&mut self, status_v1: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
297
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ChannelInstruction::VT_STATUS_V1, status_v1);
298
  }
299
  #[inline]
300
  pub fn add_deploy_v1(&mut self, deploy_v1: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
301
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ChannelInstruction::VT_DEPLOY_V1, deploy_v1);
302
  }
303
  #[inline]
304
  pub fn add_claim_v1(&mut self, claim_v1: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
305
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ChannelInstruction::VT_CLAIM_V1, claim_v1);
306
  }
307
  #[inline]
308
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ChannelInstructionBuilder<'a, 'b, A> {
309
    let start = _fbb.start_table();
310
    ChannelInstructionBuilder {
311
      fbb_: _fbb,
312
      start_: start,
313
    }
314
  }
315
  #[inline]
316
  pub fn finish(self) -> flatbuffers::WIPOffset<ChannelInstruction<'a>> {
317
    let o = self.fbb_.end_table(self.start_);
318
    flatbuffers::WIPOffset::new(o.value())
319
  }
320
}
321

            
322
impl core::fmt::Debug for ChannelInstruction<'_> {
323
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
324
    let mut ds = f.debug_struct("ChannelInstruction");
325
      ds.field("ix_type", &self.ix_type());
326
      ds.field("execute_v1", &self.execute_v1());
327
      ds.field("status_v1", &self.status_v1());
328
      ds.field("deploy_v1", &self.deploy_v1());
329
      ds.field("claim_v1", &self.claim_v1());
330
      ds.finish()
331
  }
332
}
333
#[non_exhaustive]
334
#[derive(Debug, Clone, PartialEq)]
335
pub struct ChannelInstructionT {
336
  pub ix_type: ChannelInstructionIxType,
337
  pub execute_v1: Option<Vec<u8>>,
338
  pub status_v1: Option<Vec<u8>>,
339
  pub deploy_v1: Option<Vec<u8>>,
340
  pub claim_v1: Option<Vec<u8>>,
341
}
342
impl Default for ChannelInstructionT {
343
  fn default() -> Self {
344
    Self {
345
      ix_type: ChannelInstructionIxType::ExecuteV1,
346
      execute_v1: None,
347
      status_v1: None,
348
      deploy_v1: None,
349
      claim_v1: None,
350
    }
351
  }
352
}
353
impl ChannelInstructionT {
354
  pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
355
    &self,
356
    _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
357
  ) -> flatbuffers::WIPOffset<ChannelInstruction<'b>> {
358
    let ix_type = self.ix_type;
359
    let execute_v1 = self.execute_v1.as_ref().map(|x|{
360
      _fbb.create_vector(x)
361
    });
362
    let status_v1 = self.status_v1.as_ref().map(|x|{
363
      _fbb.create_vector(x)
364
    });
365
    let deploy_v1 = self.deploy_v1.as_ref().map(|x|{
366
      _fbb.create_vector(x)
367
    });
368
    let claim_v1 = self.claim_v1.as_ref().map(|x|{
369
      _fbb.create_vector(x)
370
    });
371
    ChannelInstruction::create(_fbb, &ChannelInstructionArgs{
372
      ix_type,
373
      execute_v1,
374
      status_v1,
375
      deploy_v1,
376
      claim_v1,
377
    })
378
  }
379
}
380
#[inline]
381
/// Verifies that a buffer of bytes contains a `ChannelInstruction`
382
/// and returns it.
383
/// Note that verification is still experimental and may not
384
/// catch every error, or be maximally performant. For the
385
/// previous, unchecked, behavior use
386
/// `root_as_channel_instruction_unchecked`.
387
pub fn root_as_channel_instruction(buf: &[u8]) -> Result<ChannelInstruction, flatbuffers::InvalidFlatbuffer> {
388
  flatbuffers::root::<ChannelInstruction>(buf)
389
}
390
#[inline]
391
/// Verifies that a buffer of bytes contains a size prefixed
392
/// `ChannelInstruction` and returns it.
393
/// Note that verification is still experimental and may not
394
/// catch every error, or be maximally performant. For the
395
/// previous, unchecked, behavior use
396
/// `size_prefixed_root_as_channel_instruction_unchecked`.
397
pub fn size_prefixed_root_as_channel_instruction(buf: &[u8]) -> Result<ChannelInstruction, flatbuffers::InvalidFlatbuffer> {
398
  flatbuffers::size_prefixed_root::<ChannelInstruction>(buf)
399
}
400
#[inline]
401
/// Verifies, with the given options, that a buffer of bytes
402
/// contains a `ChannelInstruction` and returns it.
403
/// Note that verification is still experimental and may not
404
/// catch every error, or be maximally performant. For the
405
/// previous, unchecked, behavior use
406
/// `root_as_channel_instruction_unchecked`.
407
pub fn root_as_channel_instruction_with_opts<'b, 'o>(
408
  opts: &'o flatbuffers::VerifierOptions,
409
  buf: &'b [u8],
410
) -> Result<ChannelInstruction<'b>, flatbuffers::InvalidFlatbuffer> {
411
  flatbuffers::root_with_opts::<ChannelInstruction<'b>>(opts, buf)
412
}
413
#[inline]
414
/// Verifies, with the given verifier options, that a buffer of
415
/// bytes contains a size prefixed `ChannelInstruction` and returns
416
/// it. Note that verification is still experimental and may not
417
/// catch every error, or be maximally performant. For the
418
/// previous, unchecked, behavior use
419
/// `root_as_channel_instruction_unchecked`.
420
pub fn size_prefixed_root_as_channel_instruction_with_opts<'b, 'o>(
421
  opts: &'o flatbuffers::VerifierOptions,
422
  buf: &'b [u8],
423
) -> Result<ChannelInstruction<'b>, flatbuffers::InvalidFlatbuffer> {
424
  flatbuffers::size_prefixed_root_with_opts::<ChannelInstruction<'b>>(opts, buf)
425
}
426
#[inline]
427
/// Assumes, without verification, that a buffer of bytes contains a ChannelInstruction and returns it.
428
/// # Safety
429
/// Callers must trust the given bytes do indeed contain a valid `ChannelInstruction`.
430
pub unsafe fn root_as_channel_instruction_unchecked(buf: &[u8]) -> ChannelInstruction {
431
  flatbuffers::root_unchecked::<ChannelInstruction>(buf)
432
}
433
#[inline]
434
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ChannelInstruction and returns it.
435
/// # Safety
436
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ChannelInstruction`.
437
pub unsafe fn size_prefixed_root_as_channel_instruction_unchecked(buf: &[u8]) -> ChannelInstruction {
438
  flatbuffers::size_prefixed_root_unchecked::<ChannelInstruction>(buf)
439
}
440
#[inline]
441
pub fn finish_channel_instruction_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
442
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
443
    root: flatbuffers::WIPOffset<ChannelInstruction<'a>>) {
444
  fbb.finish(root, None);
445
}
446

            
447
#[inline]
448
pub fn finish_size_prefixed_channel_instruction_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset<ChannelInstruction<'a>>) {
449
  fbb.finish_size_prefixed(root, None);
450
}