1#![allow(dead_code)]
19#![allow(unused_imports)]
20
21use crate::gen::Schema::*;
22use crate::gen::SparseTensor::*;
23use crate::gen::Tensor::*;
24use flatbuffers::EndianScalar;
25use std::{cmp::Ordering, mem};
26#[deprecated(
31 since = "2.0.0",
32 note = "Use associated constants instead. This will no longer be generated in 2021."
33)]
34pub const ENUM_MIN_COMPRESSION_TYPE: i8 = 0;
35#[deprecated(
36 since = "2.0.0",
37 note = "Use associated constants instead. This will no longer be generated in 2021."
38)]
39pub const ENUM_MAX_COMPRESSION_TYPE: i8 = 1;
40#[deprecated(
41 since = "2.0.0",
42 note = "Use associated constants instead. This will no longer be generated in 2021."
43)]
44#[allow(non_camel_case_types)]
45pub const ENUM_VALUES_COMPRESSION_TYPE: [CompressionType; 2] =
46 [CompressionType::LZ4_FRAME, CompressionType::ZSTD];
47
48#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
49#[repr(transparent)]
50pub struct CompressionType(pub i8);
51#[allow(non_upper_case_globals)]
52impl CompressionType {
53 pub const LZ4_FRAME: Self = Self(0);
54 pub const ZSTD: Self = Self(1);
55
56 pub const ENUM_MIN: i8 = 0;
57 pub const ENUM_MAX: i8 = 1;
58 pub const ENUM_VALUES: &'static [Self] = &[Self::LZ4_FRAME, Self::ZSTD];
59 pub fn variant_name(self) -> Option<&'static str> {
61 match self {
62 Self::LZ4_FRAME => Some("LZ4_FRAME"),
63 Self::ZSTD => Some("ZSTD"),
64 _ => None,
65 }
66 }
67}
68impl core::fmt::Debug for CompressionType {
69 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
70 if let Some(name) = self.variant_name() {
71 f.write_str(name)
72 } else {
73 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
74 }
75 }
76}
77impl<'a> flatbuffers::Follow<'a> for CompressionType {
78 type Inner = Self;
79 #[inline]
80 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
81 let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
82 Self(b)
83 }
84}
85
86impl flatbuffers::Push for CompressionType {
87 type Output = CompressionType;
88 #[inline]
89 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
90 flatbuffers::emplace_scalar::<i8>(dst, self.0);
91 }
92}
93
94impl flatbuffers::EndianScalar for CompressionType {
95 type Scalar = i8;
96 #[inline]
97 fn to_little_endian(self) -> i8 {
98 self.0.to_le()
99 }
100 #[inline]
101 #[allow(clippy::wrong_self_convention)]
102 fn from_little_endian(v: i8) -> Self {
103 let b = i8::from_le(v);
104 Self(b)
105 }
106}
107
108impl<'a> flatbuffers::Verifiable for CompressionType {
109 #[inline]
110 fn run_verifier(
111 v: &mut flatbuffers::Verifier,
112 pos: usize,
113 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
114 use flatbuffers::Verifiable;
115 i8::run_verifier(v, pos)
116 }
117}
118
119impl flatbuffers::SimpleToVerifyInSlice for CompressionType {}
120#[deprecated(
121 since = "2.0.0",
122 note = "Use associated constants instead. This will no longer be generated in 2021."
123)]
124pub const ENUM_MIN_BODY_COMPRESSION_METHOD: i8 = 0;
125#[deprecated(
126 since = "2.0.0",
127 note = "Use associated constants instead. This will no longer be generated in 2021."
128)]
129pub const ENUM_MAX_BODY_COMPRESSION_METHOD: i8 = 0;
130#[deprecated(
131 since = "2.0.0",
132 note = "Use associated constants instead. This will no longer be generated in 2021."
133)]
134#[allow(non_camel_case_types)]
135pub const ENUM_VALUES_BODY_COMPRESSION_METHOD: [BodyCompressionMethod; 1] =
136 [BodyCompressionMethod::BUFFER];
137
138#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
142#[repr(transparent)]
143pub struct BodyCompressionMethod(pub i8);
144#[allow(non_upper_case_globals)]
145impl BodyCompressionMethod {
146 pub const BUFFER: Self = Self(0);
154
155 pub const ENUM_MIN: i8 = 0;
156 pub const ENUM_MAX: i8 = 0;
157 pub const ENUM_VALUES: &'static [Self] = &[Self::BUFFER];
158 pub fn variant_name(self) -> Option<&'static str> {
160 match self {
161 Self::BUFFER => Some("BUFFER"),
162 _ => None,
163 }
164 }
165}
166impl core::fmt::Debug for BodyCompressionMethod {
167 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
168 if let Some(name) = self.variant_name() {
169 f.write_str(name)
170 } else {
171 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
172 }
173 }
174}
175impl<'a> flatbuffers::Follow<'a> for BodyCompressionMethod {
176 type Inner = Self;
177 #[inline]
178 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
179 let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
180 Self(b)
181 }
182}
183
184impl flatbuffers::Push for BodyCompressionMethod {
185 type Output = BodyCompressionMethod;
186 #[inline]
187 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
188 flatbuffers::emplace_scalar::<i8>(dst, self.0);
189 }
190}
191
192impl flatbuffers::EndianScalar for BodyCompressionMethod {
193 type Scalar = i8;
194 #[inline]
195 fn to_little_endian(self) -> i8 {
196 self.0.to_le()
197 }
198 #[inline]
199 #[allow(clippy::wrong_self_convention)]
200 fn from_little_endian(v: i8) -> Self {
201 let b = i8::from_le(v);
202 Self(b)
203 }
204}
205
206impl<'a> flatbuffers::Verifiable for BodyCompressionMethod {
207 #[inline]
208 fn run_verifier(
209 v: &mut flatbuffers::Verifier,
210 pos: usize,
211 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
212 use flatbuffers::Verifiable;
213 i8::run_verifier(v, pos)
214 }
215}
216
217impl flatbuffers::SimpleToVerifyInSlice for BodyCompressionMethod {}
218#[deprecated(
219 since = "2.0.0",
220 note = "Use associated constants instead. This will no longer be generated in 2021."
221)]
222pub const ENUM_MIN_MESSAGE_HEADER: u8 = 0;
223#[deprecated(
224 since = "2.0.0",
225 note = "Use associated constants instead. This will no longer be generated in 2021."
226)]
227pub const ENUM_MAX_MESSAGE_HEADER: u8 = 5;
228#[deprecated(
229 since = "2.0.0",
230 note = "Use associated constants instead. This will no longer be generated in 2021."
231)]
232#[allow(non_camel_case_types)]
233pub const ENUM_VALUES_MESSAGE_HEADER: [MessageHeader; 6] = [
234 MessageHeader::NONE,
235 MessageHeader::Schema,
236 MessageHeader::DictionaryBatch,
237 MessageHeader::RecordBatch,
238 MessageHeader::Tensor,
239 MessageHeader::SparseTensor,
240];
241
242#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
251#[repr(transparent)]
252pub struct MessageHeader(pub u8);
253#[allow(non_upper_case_globals)]
254impl MessageHeader {
255 pub const NONE: Self = Self(0);
256 pub const Schema: Self = Self(1);
257 pub const DictionaryBatch: Self = Self(2);
258 pub const RecordBatch: Self = Self(3);
259 pub const Tensor: Self = Self(4);
260 pub const SparseTensor: Self = Self(5);
261
262 pub const ENUM_MIN: u8 = 0;
263 pub const ENUM_MAX: u8 = 5;
264 pub const ENUM_VALUES: &'static [Self] = &[
265 Self::NONE,
266 Self::Schema,
267 Self::DictionaryBatch,
268 Self::RecordBatch,
269 Self::Tensor,
270 Self::SparseTensor,
271 ];
272 pub fn variant_name(self) -> Option<&'static str> {
274 match self {
275 Self::NONE => Some("NONE"),
276 Self::Schema => Some("Schema"),
277 Self::DictionaryBatch => Some("DictionaryBatch"),
278 Self::RecordBatch => Some("RecordBatch"),
279 Self::Tensor => Some("Tensor"),
280 Self::SparseTensor => Some("SparseTensor"),
281 _ => None,
282 }
283 }
284}
285impl core::fmt::Debug for MessageHeader {
286 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
287 if let Some(name) = self.variant_name() {
288 f.write_str(name)
289 } else {
290 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
291 }
292 }
293}
294impl<'a> flatbuffers::Follow<'a> for MessageHeader {
295 type Inner = Self;
296 #[inline]
297 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
298 let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
299 Self(b)
300 }
301}
302
303impl flatbuffers::Push for MessageHeader {
304 type Output = MessageHeader;
305 #[inline]
306 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
307 flatbuffers::emplace_scalar::<u8>(dst, self.0);
308 }
309}
310
311impl flatbuffers::EndianScalar for MessageHeader {
312 type Scalar = u8;
313 #[inline]
314 fn to_little_endian(self) -> u8 {
315 self.0.to_le()
316 }
317 #[inline]
318 #[allow(clippy::wrong_self_convention)]
319 fn from_little_endian(v: u8) -> Self {
320 let b = u8::from_le(v);
321 Self(b)
322 }
323}
324
325impl<'a> flatbuffers::Verifiable for MessageHeader {
326 #[inline]
327 fn run_verifier(
328 v: &mut flatbuffers::Verifier,
329 pos: usize,
330 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
331 use flatbuffers::Verifiable;
332 u8::run_verifier(v, pos)
333 }
334}
335
336impl flatbuffers::SimpleToVerifyInSlice for MessageHeader {}
337pub struct MessageHeaderUnionTableOffset {}
338
339#[repr(transparent)]
350#[derive(Clone, Copy, PartialEq)]
351pub struct FieldNode(pub [u8; 16]);
352impl Default for FieldNode {
353 fn default() -> Self {
354 Self([0; 16])
355 }
356}
357impl core::fmt::Debug for FieldNode {
358 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
359 f.debug_struct("FieldNode")
360 .field("length", &self.length())
361 .field("null_count", &self.null_count())
362 .finish()
363 }
364}
365
366impl flatbuffers::SimpleToVerifyInSlice for FieldNode {}
367impl<'a> flatbuffers::Follow<'a> for FieldNode {
368 type Inner = &'a FieldNode;
369 #[inline]
370 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
371 <&'a FieldNode>::follow(buf, loc)
372 }
373}
374impl<'a> flatbuffers::Follow<'a> for &'a FieldNode {
375 type Inner = &'a FieldNode;
376 #[inline]
377 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
378 flatbuffers::follow_cast_ref::<FieldNode>(buf, loc)
379 }
380}
381impl<'b> flatbuffers::Push for FieldNode {
382 type Output = FieldNode;
383 #[inline]
384 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
385 let src =
386 ::core::slice::from_raw_parts(self as *const FieldNode as *const u8, Self::size());
387 dst.copy_from_slice(src);
388 }
389}
390
391impl<'a> flatbuffers::Verifiable for FieldNode {
392 #[inline]
393 fn run_verifier(
394 v: &mut flatbuffers::Verifier,
395 pos: usize,
396 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
397 use flatbuffers::Verifiable;
398 v.in_buffer::<Self>(pos)
399 }
400}
401
402impl<'a> FieldNode {
403 #[allow(clippy::too_many_arguments)]
404 pub fn new(length: i64, null_count: i64) -> Self {
405 let mut s = Self([0; 16]);
406 s.set_length(length);
407 s.set_null_count(null_count);
408 s
409 }
410
411 pub fn length(&self) -> i64 {
414 let mut mem = core::mem::MaybeUninit::<<i64 as EndianScalar>::Scalar>::uninit();
415 EndianScalar::from_little_endian(unsafe {
419 core::ptr::copy_nonoverlapping(
420 self.0[0..].as_ptr(),
421 mem.as_mut_ptr() as *mut u8,
422 core::mem::size_of::<<i64 as EndianScalar>::Scalar>(),
423 );
424 mem.assume_init()
425 })
426 }
427
428 pub fn set_length(&mut self, x: i64) {
429 let x_le = x.to_little_endian();
430 unsafe {
434 core::ptr::copy_nonoverlapping(
435 &x_le as *const _ as *const u8,
436 self.0[0..].as_mut_ptr(),
437 core::mem::size_of::<<i64 as EndianScalar>::Scalar>(),
438 );
439 }
440 }
441
442 pub fn null_count(&self) -> i64 {
446 let mut mem = core::mem::MaybeUninit::<<i64 as EndianScalar>::Scalar>::uninit();
447 EndianScalar::from_little_endian(unsafe {
451 core::ptr::copy_nonoverlapping(
452 self.0[8..].as_ptr(),
453 mem.as_mut_ptr() as *mut u8,
454 core::mem::size_of::<<i64 as EndianScalar>::Scalar>(),
455 );
456 mem.assume_init()
457 })
458 }
459
460 pub fn set_null_count(&mut self, x: i64) {
461 let x_le = x.to_little_endian();
462 unsafe {
466 core::ptr::copy_nonoverlapping(
467 &x_le as *const _ as *const u8,
468 self.0[8..].as_mut_ptr(),
469 core::mem::size_of::<<i64 as EndianScalar>::Scalar>(),
470 );
471 }
472 }
473}
474
475pub enum BodyCompressionOffset {}
476#[derive(Copy, Clone, PartialEq)]
477
478pub struct BodyCompression<'a> {
482 pub _tab: flatbuffers::Table<'a>,
483}
484
485impl<'a> flatbuffers::Follow<'a> for BodyCompression<'a> {
486 type Inner = BodyCompression<'a>;
487 #[inline]
488 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
489 Self {
490 _tab: flatbuffers::Table::new(buf, loc),
491 }
492 }
493}
494
495impl<'a> BodyCompression<'a> {
496 pub const VT_CODEC: flatbuffers::VOffsetT = 4;
497 pub const VT_METHOD: flatbuffers::VOffsetT = 6;
498
499 #[inline]
500 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
501 BodyCompression { _tab: table }
502 }
503 #[allow(unused_mut)]
504 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
505 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
506 args: &'args BodyCompressionArgs,
507 ) -> flatbuffers::WIPOffset<BodyCompression<'bldr>> {
508 let mut builder = BodyCompressionBuilder::new(_fbb);
509 builder.add_method(args.method);
510 builder.add_codec(args.codec);
511 builder.finish()
512 }
513
514 #[inline]
517 pub fn codec(&self) -> CompressionType {
518 unsafe {
522 self._tab
523 .get::<CompressionType>(BodyCompression::VT_CODEC, Some(CompressionType::LZ4_FRAME))
524 .unwrap()
525 }
526 }
527 #[inline]
529 pub fn method(&self) -> BodyCompressionMethod {
530 unsafe {
534 self._tab
535 .get::<BodyCompressionMethod>(
536 BodyCompression::VT_METHOD,
537 Some(BodyCompressionMethod::BUFFER),
538 )
539 .unwrap()
540 }
541 }
542}
543
544impl flatbuffers::Verifiable for BodyCompression<'_> {
545 #[inline]
546 fn run_verifier(
547 v: &mut flatbuffers::Verifier,
548 pos: usize,
549 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
550 use flatbuffers::Verifiable;
551 v.visit_table(pos)?
552 .visit_field::<CompressionType>("codec", Self::VT_CODEC, false)?
553 .visit_field::<BodyCompressionMethod>("method", Self::VT_METHOD, false)?
554 .finish();
555 Ok(())
556 }
557}
558pub struct BodyCompressionArgs {
559 pub codec: CompressionType,
560 pub method: BodyCompressionMethod,
561}
562impl<'a> Default for BodyCompressionArgs {
563 #[inline]
564 fn default() -> Self {
565 BodyCompressionArgs {
566 codec: CompressionType::LZ4_FRAME,
567 method: BodyCompressionMethod::BUFFER,
568 }
569 }
570}
571
572pub struct BodyCompressionBuilder<'a: 'b, 'b> {
573 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
574 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
575}
576impl<'a: 'b, 'b> BodyCompressionBuilder<'a, 'b> {
577 #[inline]
578 pub fn add_codec(&mut self, codec: CompressionType) {
579 self.fbb_.push_slot::<CompressionType>(
580 BodyCompression::VT_CODEC,
581 codec,
582 CompressionType::LZ4_FRAME,
583 );
584 }
585 #[inline]
586 pub fn add_method(&mut self, method: BodyCompressionMethod) {
587 self.fbb_.push_slot::<BodyCompressionMethod>(
588 BodyCompression::VT_METHOD,
589 method,
590 BodyCompressionMethod::BUFFER,
591 );
592 }
593 #[inline]
594 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BodyCompressionBuilder<'a, 'b> {
595 let start = _fbb.start_table();
596 BodyCompressionBuilder {
597 fbb_: _fbb,
598 start_: start,
599 }
600 }
601 #[inline]
602 pub fn finish(self) -> flatbuffers::WIPOffset<BodyCompression<'a>> {
603 let o = self.fbb_.end_table(self.start_);
604 flatbuffers::WIPOffset::new(o.value())
605 }
606}
607
608impl core::fmt::Debug for BodyCompression<'_> {
609 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
610 let mut ds = f.debug_struct("BodyCompression");
611 ds.field("codec", &self.codec());
612 ds.field("method", &self.method());
613 ds.finish()
614 }
615}
616pub enum RecordBatchOffset {}
617#[derive(Copy, Clone, PartialEq)]
618
619pub struct RecordBatch<'a> {
623 pub _tab: flatbuffers::Table<'a>,
624}
625
626impl<'a> flatbuffers::Follow<'a> for RecordBatch<'a> {
627 type Inner = RecordBatch<'a>;
628 #[inline]
629 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
630 Self {
631 _tab: flatbuffers::Table::new(buf, loc),
632 }
633 }
634}
635
636impl<'a> RecordBatch<'a> {
637 pub const VT_LENGTH: flatbuffers::VOffsetT = 4;
638 pub const VT_NODES: flatbuffers::VOffsetT = 6;
639 pub const VT_BUFFERS: flatbuffers::VOffsetT = 8;
640 pub const VT_COMPRESSION: flatbuffers::VOffsetT = 10;
641 pub const VT_VARIADICBUFFERCOUNTS: flatbuffers::VOffsetT = 12;
642
643 #[inline]
644 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
645 RecordBatch { _tab: table }
646 }
647 #[allow(unused_mut)]
648 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
649 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
650 args: &'args RecordBatchArgs<'args>,
651 ) -> flatbuffers::WIPOffset<RecordBatch<'bldr>> {
652 let mut builder = RecordBatchBuilder::new(_fbb);
653 builder.add_length(args.length);
654 if let Some(x) = args.variadicBufferCounts {
655 builder.add_variadicBufferCounts(x);
656 }
657 if let Some(x) = args.compression {
658 builder.add_compression(x);
659 }
660 if let Some(x) = args.buffers {
661 builder.add_buffers(x);
662 }
663 if let Some(x) = args.nodes {
664 builder.add_nodes(x);
665 }
666 builder.finish()
667 }
668
669 #[inline]
672 pub fn length(&self) -> i64 {
673 unsafe {
677 self._tab
678 .get::<i64>(RecordBatch::VT_LENGTH, Some(0))
679 .unwrap()
680 }
681 }
682 #[inline]
684 pub fn nodes(&self) -> Option<flatbuffers::Vector<'a, FieldNode>> {
685 unsafe {
689 self._tab
690 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, FieldNode>>>(
691 RecordBatch::VT_NODES,
692 None,
693 )
694 }
695 }
696 #[inline]
703 pub fn buffers(&self) -> Option<flatbuffers::Vector<'a, Buffer>> {
704 unsafe {
708 self._tab
709 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Buffer>>>(
710 RecordBatch::VT_BUFFERS,
711 None,
712 )
713 }
714 }
715 #[inline]
717 pub fn compression(&self) -> Option<BodyCompression<'a>> {
718 unsafe {
722 self._tab
723 .get::<flatbuffers::ForwardsUOffset<BodyCompression>>(
724 RecordBatch::VT_COMPRESSION,
725 None,
726 )
727 }
728 }
729 #[inline]
744 pub fn variadicBufferCounts(&self) -> Option<flatbuffers::Vector<'a, i64>> {
745 unsafe {
749 self._tab
750 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i64>>>(
751 RecordBatch::VT_VARIADICBUFFERCOUNTS,
752 None,
753 )
754 }
755 }
756}
757
758impl flatbuffers::Verifiable for RecordBatch<'_> {
759 #[inline]
760 fn run_verifier(
761 v: &mut flatbuffers::Verifier,
762 pos: usize,
763 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
764 use flatbuffers::Verifiable;
765 v.visit_table(pos)?
766 .visit_field::<i64>("length", Self::VT_LENGTH, false)?
767 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, FieldNode>>>(
768 "nodes",
769 Self::VT_NODES,
770 false,
771 )?
772 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
773 "buffers",
774 Self::VT_BUFFERS,
775 false,
776 )?
777 .visit_field::<flatbuffers::ForwardsUOffset<BodyCompression>>(
778 "compression",
779 Self::VT_COMPRESSION,
780 false,
781 )?
782 .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>(
783 "variadicBufferCounts",
784 Self::VT_VARIADICBUFFERCOUNTS,
785 false,
786 )?
787 .finish();
788 Ok(())
789 }
790}
791pub struct RecordBatchArgs<'a> {
792 pub length: i64,
793 pub nodes: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, FieldNode>>>,
794 pub buffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Buffer>>>,
795 pub compression: Option<flatbuffers::WIPOffset<BodyCompression<'a>>>,
796 pub variadicBufferCounts: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i64>>>,
797}
798impl<'a> Default for RecordBatchArgs<'a> {
799 #[inline]
800 fn default() -> Self {
801 RecordBatchArgs {
802 length: 0,
803 nodes: None,
804 buffers: None,
805 compression: None,
806 variadicBufferCounts: None,
807 }
808 }
809}
810
811pub struct RecordBatchBuilder<'a: 'b, 'b> {
812 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
813 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
814}
815impl<'a: 'b, 'b> RecordBatchBuilder<'a, 'b> {
816 #[inline]
817 pub fn add_length(&mut self, length: i64) {
818 self.fbb_
819 .push_slot::<i64>(RecordBatch::VT_LENGTH, length, 0);
820 }
821 #[inline]
822 pub fn add_nodes(&mut self, nodes: flatbuffers::WIPOffset<flatbuffers::Vector<'b, FieldNode>>) {
823 self.fbb_
824 .push_slot_always::<flatbuffers::WIPOffset<_>>(RecordBatch::VT_NODES, nodes);
825 }
826 #[inline]
827 pub fn add_buffers(
828 &mut self,
829 buffers: flatbuffers::WIPOffset<flatbuffers::Vector<'b, Buffer>>,
830 ) {
831 self.fbb_
832 .push_slot_always::<flatbuffers::WIPOffset<_>>(RecordBatch::VT_BUFFERS, buffers);
833 }
834 #[inline]
835 pub fn add_compression(&mut self, compression: flatbuffers::WIPOffset<BodyCompression<'b>>) {
836 self.fbb_
837 .push_slot_always::<flatbuffers::WIPOffset<BodyCompression>>(
838 RecordBatch::VT_COMPRESSION,
839 compression,
840 );
841 }
842 #[inline]
843 pub fn add_variadicBufferCounts(
844 &mut self,
845 variadicBufferCounts: flatbuffers::WIPOffset<flatbuffers::Vector<'b, i64>>,
846 ) {
847 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
848 RecordBatch::VT_VARIADICBUFFERCOUNTS,
849 variadicBufferCounts,
850 );
851 }
852 #[inline]
853 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> RecordBatchBuilder<'a, 'b> {
854 let start = _fbb.start_table();
855 RecordBatchBuilder {
856 fbb_: _fbb,
857 start_: start,
858 }
859 }
860 #[inline]
861 pub fn finish(self) -> flatbuffers::WIPOffset<RecordBatch<'a>> {
862 let o = self.fbb_.end_table(self.start_);
863 flatbuffers::WIPOffset::new(o.value())
864 }
865}
866
867impl core::fmt::Debug for RecordBatch<'_> {
868 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
869 let mut ds = f.debug_struct("RecordBatch");
870 ds.field("length", &self.length());
871 ds.field("nodes", &self.nodes());
872 ds.field("buffers", &self.buffers());
873 ds.field("compression", &self.compression());
874 ds.field("variadicBufferCounts", &self.variadicBufferCounts());
875 ds.finish()
876 }
877}
878pub enum DictionaryBatchOffset {}
879#[derive(Copy, Clone, PartialEq)]
880
881pub struct DictionaryBatch<'a> {
888 pub _tab: flatbuffers::Table<'a>,
889}
890
891impl<'a> flatbuffers::Follow<'a> for DictionaryBatch<'a> {
892 type Inner = DictionaryBatch<'a>;
893 #[inline]
894 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
895 Self {
896 _tab: flatbuffers::Table::new(buf, loc),
897 }
898 }
899}
900
901impl<'a> DictionaryBatch<'a> {
902 pub const VT_ID: flatbuffers::VOffsetT = 4;
903 pub const VT_DATA: flatbuffers::VOffsetT = 6;
904 pub const VT_ISDELTA: flatbuffers::VOffsetT = 8;
905
906 #[inline]
907 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
908 DictionaryBatch { _tab: table }
909 }
910 #[allow(unused_mut)]
911 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
912 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
913 args: &'args DictionaryBatchArgs<'args>,
914 ) -> flatbuffers::WIPOffset<DictionaryBatch<'bldr>> {
915 let mut builder = DictionaryBatchBuilder::new(_fbb);
916 builder.add_id(args.id);
917 if let Some(x) = args.data {
918 builder.add_data(x);
919 }
920 builder.add_isDelta(args.isDelta);
921 builder.finish()
922 }
923
924 #[inline]
925 pub fn id(&self) -> i64 {
926 unsafe {
930 self._tab
931 .get::<i64>(DictionaryBatch::VT_ID, Some(0))
932 .unwrap()
933 }
934 }
935 #[inline]
936 pub fn data(&self) -> Option<RecordBatch<'a>> {
937 unsafe {
941 self._tab
942 .get::<flatbuffers::ForwardsUOffset<RecordBatch>>(DictionaryBatch::VT_DATA, None)
943 }
944 }
945 #[inline]
949 pub fn isDelta(&self) -> bool {
950 unsafe {
954 self._tab
955 .get::<bool>(DictionaryBatch::VT_ISDELTA, Some(false))
956 .unwrap()
957 }
958 }
959}
960
961impl flatbuffers::Verifiable for DictionaryBatch<'_> {
962 #[inline]
963 fn run_verifier(
964 v: &mut flatbuffers::Verifier,
965 pos: usize,
966 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
967 use flatbuffers::Verifiable;
968 v.visit_table(pos)?
969 .visit_field::<i64>("id", Self::VT_ID, false)?
970 .visit_field::<flatbuffers::ForwardsUOffset<RecordBatch>>("data", Self::VT_DATA, false)?
971 .visit_field::<bool>("isDelta", Self::VT_ISDELTA, false)?
972 .finish();
973 Ok(())
974 }
975}
976pub struct DictionaryBatchArgs<'a> {
977 pub id: i64,
978 pub data: Option<flatbuffers::WIPOffset<RecordBatch<'a>>>,
979 pub isDelta: bool,
980}
981impl<'a> Default for DictionaryBatchArgs<'a> {
982 #[inline]
983 fn default() -> Self {
984 DictionaryBatchArgs {
985 id: 0,
986 data: None,
987 isDelta: false,
988 }
989 }
990}
991
992pub struct DictionaryBatchBuilder<'a: 'b, 'b> {
993 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
994 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
995}
996impl<'a: 'b, 'b> DictionaryBatchBuilder<'a, 'b> {
997 #[inline]
998 pub fn add_id(&mut self, id: i64) {
999 self.fbb_.push_slot::<i64>(DictionaryBatch::VT_ID, id, 0);
1000 }
1001 #[inline]
1002 pub fn add_data(&mut self, data: flatbuffers::WIPOffset<RecordBatch<'b>>) {
1003 self.fbb_
1004 .push_slot_always::<flatbuffers::WIPOffset<RecordBatch>>(
1005 DictionaryBatch::VT_DATA,
1006 data,
1007 );
1008 }
1009 #[inline]
1010 pub fn add_isDelta(&mut self, isDelta: bool) {
1011 self.fbb_
1012 .push_slot::<bool>(DictionaryBatch::VT_ISDELTA, isDelta, false);
1013 }
1014 #[inline]
1015 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> DictionaryBatchBuilder<'a, 'b> {
1016 let start = _fbb.start_table();
1017 DictionaryBatchBuilder {
1018 fbb_: _fbb,
1019 start_: start,
1020 }
1021 }
1022 #[inline]
1023 pub fn finish(self) -> flatbuffers::WIPOffset<DictionaryBatch<'a>> {
1024 let o = self.fbb_.end_table(self.start_);
1025 flatbuffers::WIPOffset::new(o.value())
1026 }
1027}
1028
1029impl core::fmt::Debug for DictionaryBatch<'_> {
1030 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1031 let mut ds = f.debug_struct("DictionaryBatch");
1032 ds.field("id", &self.id());
1033 ds.field("data", &self.data());
1034 ds.field("isDelta", &self.isDelta());
1035 ds.finish()
1036 }
1037}
1038pub enum MessageOffset {}
1039#[derive(Copy, Clone, PartialEq)]
1040
1041pub struct Message<'a> {
1042 pub _tab: flatbuffers::Table<'a>,
1043}
1044
1045impl<'a> flatbuffers::Follow<'a> for Message<'a> {
1046 type Inner = Message<'a>;
1047 #[inline]
1048 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
1049 Self {
1050 _tab: flatbuffers::Table::new(buf, loc),
1051 }
1052 }
1053}
1054
1055impl<'a> Message<'a> {
1056 pub const VT_VERSION: flatbuffers::VOffsetT = 4;
1057 pub const VT_HEADER_TYPE: flatbuffers::VOffsetT = 6;
1058 pub const VT_HEADER: flatbuffers::VOffsetT = 8;
1059 pub const VT_BODYLENGTH: flatbuffers::VOffsetT = 10;
1060 pub const VT_CUSTOM_METADATA: flatbuffers::VOffsetT = 12;
1061
1062 #[inline]
1063 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
1064 Message { _tab: table }
1065 }
1066 #[allow(unused_mut)]
1067 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
1068 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
1069 args: &'args MessageArgs<'args>,
1070 ) -> flatbuffers::WIPOffset<Message<'bldr>> {
1071 let mut builder = MessageBuilder::new(_fbb);
1072 builder.add_bodyLength(args.bodyLength);
1073 if let Some(x) = args.custom_metadata {
1074 builder.add_custom_metadata(x);
1075 }
1076 if let Some(x) = args.header {
1077 builder.add_header(x);
1078 }
1079 builder.add_version(args.version);
1080 builder.add_header_type(args.header_type);
1081 builder.finish()
1082 }
1083
1084 #[inline]
1085 pub fn version(&self) -> MetadataVersion {
1086 unsafe {
1090 self._tab
1091 .get::<MetadataVersion>(Message::VT_VERSION, Some(MetadataVersion::V1))
1092 .unwrap()
1093 }
1094 }
1095 #[inline]
1096 pub fn header_type(&self) -> MessageHeader {
1097 unsafe {
1101 self._tab
1102 .get::<MessageHeader>(Message::VT_HEADER_TYPE, Some(MessageHeader::NONE))
1103 .unwrap()
1104 }
1105 }
1106 #[inline]
1107 pub fn header(&self) -> Option<flatbuffers::Table<'a>> {
1108 unsafe {
1112 self._tab
1113 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
1114 Message::VT_HEADER,
1115 None,
1116 )
1117 }
1118 }
1119 #[inline]
1120 pub fn bodyLength(&self) -> i64 {
1121 unsafe {
1125 self._tab
1126 .get::<i64>(Message::VT_BODYLENGTH, Some(0))
1127 .unwrap()
1128 }
1129 }
1130 #[inline]
1131 pub fn custom_metadata(
1132 &self,
1133 ) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
1134 unsafe {
1138 self._tab.get::<flatbuffers::ForwardsUOffset<
1139 flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue>>,
1140 >>(Message::VT_CUSTOM_METADATA, None)
1141 }
1142 }
1143 #[inline]
1144 #[allow(non_snake_case)]
1145 pub fn header_as_schema(&self) -> Option<Schema<'a>> {
1146 if self.header_type() == MessageHeader::Schema {
1147 self.header().map(|t| {
1148 unsafe { Schema::init_from_table(t) }
1152 })
1153 } else {
1154 None
1155 }
1156 }
1157
1158 #[inline]
1159 #[allow(non_snake_case)]
1160 pub fn header_as_dictionary_batch(&self) -> Option<DictionaryBatch<'a>> {
1161 if self.header_type() == MessageHeader::DictionaryBatch {
1162 self.header().map(|t| {
1163 unsafe { DictionaryBatch::init_from_table(t) }
1167 })
1168 } else {
1169 None
1170 }
1171 }
1172
1173 #[inline]
1174 #[allow(non_snake_case)]
1175 pub fn header_as_record_batch(&self) -> Option<RecordBatch<'a>> {
1176 if self.header_type() == MessageHeader::RecordBatch {
1177 self.header().map(|t| {
1178 unsafe { RecordBatch::init_from_table(t) }
1182 })
1183 } else {
1184 None
1185 }
1186 }
1187
1188 #[inline]
1189 #[allow(non_snake_case)]
1190 pub fn header_as_tensor(&self) -> Option<Tensor<'a>> {
1191 if self.header_type() == MessageHeader::Tensor {
1192 self.header().map(|t| {
1193 unsafe { Tensor::init_from_table(t) }
1197 })
1198 } else {
1199 None
1200 }
1201 }
1202
1203 #[inline]
1204 #[allow(non_snake_case)]
1205 pub fn header_as_sparse_tensor(&self) -> Option<SparseTensor<'a>> {
1206 if self.header_type() == MessageHeader::SparseTensor {
1207 self.header().map(|t| {
1208 unsafe { SparseTensor::init_from_table(t) }
1212 })
1213 } else {
1214 None
1215 }
1216 }
1217}
1218
1219impl flatbuffers::Verifiable for Message<'_> {
1220 #[inline]
1221 fn run_verifier(
1222 v: &mut flatbuffers::Verifier,
1223 pos: usize,
1224 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
1225 use flatbuffers::Verifiable;
1226 v.visit_table(pos)?
1227 .visit_field::<MetadataVersion>("version", Self::VT_VERSION, false)?
1228 .visit_union::<MessageHeader, _>(
1229 "header_type",
1230 Self::VT_HEADER_TYPE,
1231 "header",
1232 Self::VT_HEADER,
1233 false,
1234 |key, v, pos| match key {
1235 MessageHeader::Schema => v
1236 .verify_union_variant::<flatbuffers::ForwardsUOffset<Schema>>(
1237 "MessageHeader::Schema",
1238 pos,
1239 ),
1240 MessageHeader::DictionaryBatch => v
1241 .verify_union_variant::<flatbuffers::ForwardsUOffset<DictionaryBatch>>(
1242 "MessageHeader::DictionaryBatch",
1243 pos,
1244 ),
1245 MessageHeader::RecordBatch => v
1246 .verify_union_variant::<flatbuffers::ForwardsUOffset<RecordBatch>>(
1247 "MessageHeader::RecordBatch",
1248 pos,
1249 ),
1250 MessageHeader::Tensor => v
1251 .verify_union_variant::<flatbuffers::ForwardsUOffset<Tensor>>(
1252 "MessageHeader::Tensor",
1253 pos,
1254 ),
1255 MessageHeader::SparseTensor => v
1256 .verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensor>>(
1257 "MessageHeader::SparseTensor",
1258 pos,
1259 ),
1260 _ => Ok(()),
1261 },
1262 )?
1263 .visit_field::<i64>("bodyLength", Self::VT_BODYLENGTH, false)?
1264 .visit_field::<flatbuffers::ForwardsUOffset<
1265 flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<KeyValue>>,
1266 >>("custom_metadata", Self::VT_CUSTOM_METADATA, false)?
1267 .finish();
1268 Ok(())
1269 }
1270}
1271pub struct MessageArgs<'a> {
1272 pub version: MetadataVersion,
1273 pub header_type: MessageHeader,
1274 pub header: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
1275 pub bodyLength: i64,
1276 pub custom_metadata: Option<
1277 flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue<'a>>>>,
1278 >,
1279}
1280impl<'a> Default for MessageArgs<'a> {
1281 #[inline]
1282 fn default() -> Self {
1283 MessageArgs {
1284 version: MetadataVersion::V1,
1285 header_type: MessageHeader::NONE,
1286 header: None,
1287 bodyLength: 0,
1288 custom_metadata: None,
1289 }
1290 }
1291}
1292
1293pub struct MessageBuilder<'a: 'b, 'b> {
1294 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
1295 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
1296}
1297impl<'a: 'b, 'b> MessageBuilder<'a, 'b> {
1298 #[inline]
1299 pub fn add_version(&mut self, version: MetadataVersion) {
1300 self.fbb_
1301 .push_slot::<MetadataVersion>(Message::VT_VERSION, version, MetadataVersion::V1);
1302 }
1303 #[inline]
1304 pub fn add_header_type(&mut self, header_type: MessageHeader) {
1305 self.fbb_.push_slot::<MessageHeader>(
1306 Message::VT_HEADER_TYPE,
1307 header_type,
1308 MessageHeader::NONE,
1309 );
1310 }
1311 #[inline]
1312 pub fn add_header(&mut self, header: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
1313 self.fbb_
1314 .push_slot_always::<flatbuffers::WIPOffset<_>>(Message::VT_HEADER, header);
1315 }
1316 #[inline]
1317 pub fn add_bodyLength(&mut self, bodyLength: i64) {
1318 self.fbb_
1319 .push_slot::<i64>(Message::VT_BODYLENGTH, bodyLength, 0);
1320 }
1321 #[inline]
1322 pub fn add_custom_metadata(
1323 &mut self,
1324 custom_metadata: flatbuffers::WIPOffset<
1325 flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<KeyValue<'b>>>,
1326 >,
1327 ) {
1328 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
1329 Message::VT_CUSTOM_METADATA,
1330 custom_metadata,
1331 );
1332 }
1333 #[inline]
1334 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MessageBuilder<'a, 'b> {
1335 let start = _fbb.start_table();
1336 MessageBuilder {
1337 fbb_: _fbb,
1338 start_: start,
1339 }
1340 }
1341 #[inline]
1342 pub fn finish(self) -> flatbuffers::WIPOffset<Message<'a>> {
1343 let o = self.fbb_.end_table(self.start_);
1344 flatbuffers::WIPOffset::new(o.value())
1345 }
1346}
1347
1348impl core::fmt::Debug for Message<'_> {
1349 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1350 let mut ds = f.debug_struct("Message");
1351 ds.field("version", &self.version());
1352 ds.field("header_type", &self.header_type());
1353 match self.header_type() {
1354 MessageHeader::Schema => {
1355 if let Some(x) = self.header_as_schema() {
1356 ds.field("header", &x)
1357 } else {
1358 ds.field(
1359 "header",
1360 &"InvalidFlatbuffer: Union discriminant does not match value.",
1361 )
1362 }
1363 }
1364 MessageHeader::DictionaryBatch => {
1365 if let Some(x) = self.header_as_dictionary_batch() {
1366 ds.field("header", &x)
1367 } else {
1368 ds.field(
1369 "header",
1370 &"InvalidFlatbuffer: Union discriminant does not match value.",
1371 )
1372 }
1373 }
1374 MessageHeader::RecordBatch => {
1375 if let Some(x) = self.header_as_record_batch() {
1376 ds.field("header", &x)
1377 } else {
1378 ds.field(
1379 "header",
1380 &"InvalidFlatbuffer: Union discriminant does not match value.",
1381 )
1382 }
1383 }
1384 MessageHeader::Tensor => {
1385 if let Some(x) = self.header_as_tensor() {
1386 ds.field("header", &x)
1387 } else {
1388 ds.field(
1389 "header",
1390 &"InvalidFlatbuffer: Union discriminant does not match value.",
1391 )
1392 }
1393 }
1394 MessageHeader::SparseTensor => {
1395 if let Some(x) = self.header_as_sparse_tensor() {
1396 ds.field("header", &x)
1397 } else {
1398 ds.field(
1399 "header",
1400 &"InvalidFlatbuffer: Union discriminant does not match value.",
1401 )
1402 }
1403 }
1404 _ => {
1405 let x: Option<()> = None;
1406 ds.field("header", &x)
1407 }
1408 };
1409 ds.field("bodyLength", &self.bodyLength());
1410 ds.field("custom_metadata", &self.custom_metadata());
1411 ds.finish()
1412 }
1413}
1414#[inline]
1415pub fn root_as_message(buf: &[u8]) -> Result<Message, flatbuffers::InvalidFlatbuffer> {
1422 flatbuffers::root::<Message>(buf)
1423}
1424#[inline]
1425pub fn size_prefixed_root_as_message(
1432 buf: &[u8],
1433) -> Result<Message, flatbuffers::InvalidFlatbuffer> {
1434 flatbuffers::size_prefixed_root::<Message>(buf)
1435}
1436#[inline]
1437pub fn root_as_message_with_opts<'b, 'o>(
1444 opts: &'o flatbuffers::VerifierOptions,
1445 buf: &'b [u8],
1446) -> Result<Message<'b>, flatbuffers::InvalidFlatbuffer> {
1447 flatbuffers::root_with_opts::<Message<'b>>(opts, buf)
1448}
1449#[inline]
1450pub fn size_prefixed_root_as_message_with_opts<'b, 'o>(
1457 opts: &'o flatbuffers::VerifierOptions,
1458 buf: &'b [u8],
1459) -> Result<Message<'b>, flatbuffers::InvalidFlatbuffer> {
1460 flatbuffers::size_prefixed_root_with_opts::<Message<'b>>(opts, buf)
1461}
1462#[inline]
1463pub unsafe fn root_as_message_unchecked(buf: &[u8]) -> Message {
1467 flatbuffers::root_unchecked::<Message>(buf)
1468}
1469#[inline]
1470pub unsafe fn size_prefixed_root_as_message_unchecked(buf: &[u8]) -> Message {
1474 flatbuffers::size_prefixed_root_unchecked::<Message>(buf)
1475}
1476#[inline]
1477pub fn finish_message_buffer<'a, 'b>(
1478 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
1479 root: flatbuffers::WIPOffset<Message<'a>>,
1480) {
1481 fbb.finish(root, None);
1482}
1483
1484#[inline]
1485pub fn finish_size_prefixed_message_buffer<'a, 'b>(
1486 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
1487 root: flatbuffers::WIPOffset<Message<'a>>,
1488) {
1489 fbb.finish_size_prefixed(root, None);
1490}