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
pub enum ClaimV1Offset {}
13
#[derive(Copy, Clone, PartialEq)]
14

            
15
pub struct ClaimV1<'a> {
16
  pub _tab: flatbuffers::Table<'a>,
17
}
18

            
19
impl<'a> flatbuffers::Follow<'a> for ClaimV1<'a> {
20
  type Inner = ClaimV1<'a>;
21
  #[inline]
22
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
23
    Self { _tab: flatbuffers::Table::new(buf, loc) }
24
  }
25
}
26

            
27
impl<'a> ClaimV1<'a> {
28
  pub const VT_EXECUTION_ID: flatbuffers::VOffsetT = 4;
29
  pub const VT_BLOCK_COMMITMENT: flatbuffers::VOffsetT = 6;
30

            
31
  #[inline]
32
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
33
    ClaimV1 { _tab: table }
34
  }
35
  #[allow(unused_mut)]
36
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
37
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
38
    args: &'args ClaimV1Args<'args>
39
  ) -> flatbuffers::WIPOffset<ClaimV1<'bldr>> {
40
    let mut builder = ClaimV1Builder::new(_fbb);
41
    builder.add_block_commitment(args.block_commitment);
42
    if let Some(x) = args.execution_id { builder.add_execution_id(x); }
43
    builder.finish()
44
  }
45

            
46
  pub fn unpack(&self) -> ClaimV1T {
47
    let execution_id = self.execution_id().map(|x| {
48
      x.to_string()
49
    });
50
    let block_commitment = self.block_commitment();
51
    ClaimV1T {
52
      execution_id,
53
      block_commitment,
54
    }
55
  }
56

            
57
  #[inline]
58
  pub fn execution_id(&self) -> Option<&'a str> {
59
    // Safety:
60
    // Created from valid Table for this object
61
    // which contains a valid value in this slot
62
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(ClaimV1::VT_EXECUTION_ID, None)}
63
  }
64
  #[inline]
65
  pub fn block_commitment(&self) -> u64 {
66
    // Safety:
67
    // Created from valid Table for this object
68
    // which contains a valid value in this slot
69
    unsafe { self._tab.get::<u64>(ClaimV1::VT_BLOCK_COMMITMENT, Some(0)).unwrap()}
70
  }
71
}
72

            
73
impl flatbuffers::Verifiable for ClaimV1<'_> {
74
  #[inline]
75
  fn run_verifier(
76
    v: &mut flatbuffers::Verifier, pos: usize
77
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
78
    use self::flatbuffers::Verifiable;
79
    v.visit_table(pos)?
80
     .visit_field::<flatbuffers::ForwardsUOffset<&str>>("execution_id", Self::VT_EXECUTION_ID, false)?
81
     .visit_field::<u64>("block_commitment", Self::VT_BLOCK_COMMITMENT, false)?
82
     .finish();
83
    Ok(())
84
  }
85
}
86
pub struct ClaimV1Args<'a> {
87
    pub execution_id: Option<flatbuffers::WIPOffset<&'a str>>,
88
    pub block_commitment: u64,
89
}
90
impl<'a> Default for ClaimV1Args<'a> {
91
  #[inline]
92
  fn default() -> Self {
93
    ClaimV1Args {
94
      execution_id: None,
95
      block_commitment: 0,
96
    }
97
  }
98
}
99

            
100
pub struct ClaimV1Builder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
101
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
102
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
103
}
104
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ClaimV1Builder<'a, 'b, A> {
105
  #[inline]
106
  pub fn add_execution_id(&mut self, execution_id: flatbuffers::WIPOffset<&'b  str>) {
107
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ClaimV1::VT_EXECUTION_ID, execution_id);
108
  }
109
  #[inline]
110
  pub fn add_block_commitment(&mut self, block_commitment: u64) {
111
    self.fbb_.push_slot::<u64>(ClaimV1::VT_BLOCK_COMMITMENT, block_commitment, 0);
112
  }
113
  #[inline]
114
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ClaimV1Builder<'a, 'b, A> {
115
    let start = _fbb.start_table();
116
    ClaimV1Builder {
117
      fbb_: _fbb,
118
      start_: start,
119
    }
120
  }
121
  #[inline]
122
  pub fn finish(self) -> flatbuffers::WIPOffset<ClaimV1<'a>> {
123
    let o = self.fbb_.end_table(self.start_);
124
    flatbuffers::WIPOffset::new(o.value())
125
  }
126
}
127

            
128
impl core::fmt::Debug for ClaimV1<'_> {
129
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
130
    let mut ds = f.debug_struct("ClaimV1");
131
      ds.field("execution_id", &self.execution_id());
132
      ds.field("block_commitment", &self.block_commitment());
133
      ds.finish()
134
  }
135
}
136
#[non_exhaustive]
137
#[derive(Debug, Clone, PartialEq)]
138
pub struct ClaimV1T {
139
  pub execution_id: Option<String>,
140
  pub block_commitment: u64,
141
}
142
impl Default for ClaimV1T {
143
  fn default() -> Self {
144
    Self {
145
      execution_id: None,
146
      block_commitment: 0,
147
    }
148
  }
149
}
150
impl ClaimV1T {
151
  pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
152
    &self,
153
    _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
154
  ) -> flatbuffers::WIPOffset<ClaimV1<'b>> {
155
    let execution_id = self.execution_id.as_ref().map(|x|{
156
      _fbb.create_string(x)
157
    });
158
    let block_commitment = self.block_commitment;
159
    ClaimV1::create(_fbb, &ClaimV1Args{
160
      execution_id,
161
      block_commitment,
162
    })
163
  }
164
}
165
#[inline]
166
/// Verifies that a buffer of bytes contains a `ClaimV1`
167
/// and returns it.
168
/// Note that verification is still experimental and may not
169
/// catch every error, or be maximally performant. For the
170
/// previous, unchecked, behavior use
171
/// `root_as_claim_v1_unchecked`.
172
pub fn root_as_claim_v1(buf: &[u8]) -> Result<ClaimV1, flatbuffers::InvalidFlatbuffer> {
173
  flatbuffers::root::<ClaimV1>(buf)
174
}
175
#[inline]
176
/// Verifies that a buffer of bytes contains a size prefixed
177
/// `ClaimV1` and returns it.
178
/// Note that verification is still experimental and may not
179
/// catch every error, or be maximally performant. For the
180
/// previous, unchecked, behavior use
181
/// `size_prefixed_root_as_claim_v1_unchecked`.
182
pub fn size_prefixed_root_as_claim_v1(buf: &[u8]) -> Result<ClaimV1, flatbuffers::InvalidFlatbuffer> {
183
  flatbuffers::size_prefixed_root::<ClaimV1>(buf)
184
}
185
#[inline]
186
/// Verifies, with the given options, that a buffer of bytes
187
/// contains a `ClaimV1` and returns it.
188
/// Note that verification is still experimental and may not
189
/// catch every error, or be maximally performant. For the
190
/// previous, unchecked, behavior use
191
/// `root_as_claim_v1_unchecked`.
192
pub fn root_as_claim_v1_with_opts<'b, 'o>(
193
  opts: &'o flatbuffers::VerifierOptions,
194
  buf: &'b [u8],
195
) -> Result<ClaimV1<'b>, flatbuffers::InvalidFlatbuffer> {
196
  flatbuffers::root_with_opts::<ClaimV1<'b>>(opts, buf)
197
}
198
#[inline]
199
/// Verifies, with the given verifier options, that a buffer of
200
/// bytes contains a size prefixed `ClaimV1` and returns
201
/// it. Note that verification is still experimental and may not
202
/// catch every error, or be maximally performant. For the
203
/// previous, unchecked, behavior use
204
/// `root_as_claim_v1_unchecked`.
205
pub fn size_prefixed_root_as_claim_v1_with_opts<'b, 'o>(
206
  opts: &'o flatbuffers::VerifierOptions,
207
  buf: &'b [u8],
208
) -> Result<ClaimV1<'b>, flatbuffers::InvalidFlatbuffer> {
209
  flatbuffers::size_prefixed_root_with_opts::<ClaimV1<'b>>(opts, buf)
210
}
211
#[inline]
212
/// Assumes, without verification, that a buffer of bytes contains a ClaimV1 and returns it.
213
/// # Safety
214
/// Callers must trust the given bytes do indeed contain a valid `ClaimV1`.
215
pub unsafe fn root_as_claim_v1_unchecked(buf: &[u8]) -> ClaimV1 {
216
  flatbuffers::root_unchecked::<ClaimV1>(buf)
217
}
218
#[inline]
219
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ClaimV1 and returns it.
220
/// # Safety
221
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ClaimV1`.
222
pub unsafe fn size_prefixed_root_as_claim_v1_unchecked(buf: &[u8]) -> ClaimV1 {
223
  flatbuffers::size_prefixed_root_unchecked::<ClaimV1>(buf)
224
}
225
#[inline]
226
pub fn finish_claim_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
227
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
228
    root: flatbuffers::WIPOffset<ClaimV1<'a>>) {
229
  fbb.finish(root, None);
230
}
231

            
232
#[inline]
233
pub fn finish_size_prefixed_claim_v1_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset<ClaimV1<'a>>) {
234
  fbb.finish_size_prefixed(root, None);
235
}