polars_arrow_format/ipc/generated.rs
1pub use root::*;
2
3const _: () = ::planus::check_version_compatibility("planus-1.1.1");
4
5/// The root namespace
6///
7/// Generated from these locations:
8/// * File `File.fbs`
9#[no_implicit_prelude]
10#[allow(dead_code, clippy::needless_lifetimes)]
11mod root {
12 /// The namespace `org`
13 ///
14 /// Generated from these locations:
15 /// * File `File.fbs`
16 pub mod org {
17 /// The namespace `org.apache`
18 ///
19 /// Generated from these locations:
20 /// * File `File.fbs`
21 pub mod apache {
22 /// The namespace `org.apache.arrow`
23 ///
24 /// Generated from these locations:
25 /// * File `File.fbs`
26 pub mod arrow {
27 /// The namespace `org.apache.arrow.flatbuf`
28 ///
29 /// Generated from these locations:
30 /// * File `File.fbs`
31 /// * File `Schema.fbs`
32 /// * File `Message.fbs`
33 /// * File `SparseTensor.fbs`
34 /// * File `Tensor.fbs`
35 pub mod flatbuf {
36 /// ----------------------------------------------------------------------
37 /// Arrow File metadata
38 ///
39 ///
40 /// Generated from these locations:
41 /// * Table `Footer` in the file `File.fbs:26`
42 #[derive(
43 Clone,
44 Debug,
45 PartialEq,
46 PartialOrd,
47 Eq,
48 Ord,
49 Hash,
50 ::serde::Serialize,
51 ::serde::Deserialize,
52 )]
53 pub struct Footer {
54 /// The field `version` in the table `Footer`
55 pub version: self::MetadataVersion,
56 /// The field `schema` in the table `Footer`
57 pub schema:
58 ::core::option::Option<::planus::alloc::boxed::Box<self::Schema>>,
59 /// The field `dictionaries` in the table `Footer`
60 pub dictionaries:
61 ::core::option::Option<::planus::alloc::vec::Vec<self::Block>>,
62 /// The field `recordBatches` in the table `Footer`
63 pub record_batches:
64 ::core::option::Option<::planus::alloc::vec::Vec<self::Block>>,
65 /// User-defined metadata
66 pub custom_metadata:
67 ::core::option::Option<::planus::alloc::vec::Vec<self::KeyValue>>,
68 }
69
70 #[allow(clippy::derivable_impls)]
71 impl ::core::default::Default for Footer {
72 fn default() -> Self {
73 Self {
74 version: self::MetadataVersion::V1,
75 schema: ::core::default::Default::default(),
76 dictionaries: ::core::default::Default::default(),
77 record_batches: ::core::default::Default::default(),
78 custom_metadata: ::core::default::Default::default(),
79 }
80 }
81 }
82
83 impl Footer {
84 /// Creates a [FooterBuilder] for serializing an instance of this table.
85 #[inline]
86 pub fn builder() -> FooterBuilder<()> {
87 FooterBuilder(())
88 }
89
90 #[allow(clippy::too_many_arguments)]
91 pub fn create(
92 builder: &mut ::planus::Builder,
93 field_version: impl ::planus::WriteAsDefault<
94 self::MetadataVersion,
95 self::MetadataVersion,
96 >,
97 field_schema: impl ::planus::WriteAsOptional<::planus::Offset<self::Schema>>,
98 field_dictionaries: impl ::planus::WriteAsOptional<
99 ::planus::Offset<[self::Block]>,
100 >,
101 field_record_batches: impl ::planus::WriteAsOptional<
102 ::planus::Offset<[self::Block]>,
103 >,
104 field_custom_metadata: impl ::planus::WriteAsOptional<
105 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
106 >,
107 ) -> ::planus::Offset<Self> {
108 let prepared_version =
109 field_version.prepare(builder, &self::MetadataVersion::V1);
110 let prepared_schema = field_schema.prepare(builder);
111 let prepared_dictionaries = field_dictionaries.prepare(builder);
112 let prepared_record_batches = field_record_batches.prepare(builder);
113 let prepared_custom_metadata = field_custom_metadata.prepare(builder);
114
115 let mut table_writer: ::planus::table_writer::TableWriter<14> =
116 ::core::default::Default::default();
117 if prepared_schema.is_some() {
118 table_writer.write_entry::<::planus::Offset<self::Schema>>(1);
119 }
120 if prepared_dictionaries.is_some() {
121 table_writer.write_entry::<::planus::Offset<[self::Block]>>(2);
122 }
123 if prepared_record_batches.is_some() {
124 table_writer.write_entry::<::planus::Offset<[self::Block]>>(3);
125 }
126 if prepared_custom_metadata.is_some() {
127 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::KeyValue>]>>(4);
128 }
129 if prepared_version.is_some() {
130 table_writer.write_entry::<self::MetadataVersion>(0);
131 }
132
133 unsafe {
134 table_writer.finish(builder, |object_writer| {
135 if let ::core::option::Option::Some(prepared_schema) =
136 prepared_schema
137 {
138 object_writer.write::<_, _, 4>(&prepared_schema);
139 }
140 if let ::core::option::Option::Some(prepared_dictionaries) =
141 prepared_dictionaries
142 {
143 object_writer.write::<_, _, 4>(&prepared_dictionaries);
144 }
145 if let ::core::option::Option::Some(prepared_record_batches) =
146 prepared_record_batches
147 {
148 object_writer.write::<_, _, 4>(&prepared_record_batches);
149 }
150 if let ::core::option::Option::Some(prepared_custom_metadata) =
151 prepared_custom_metadata
152 {
153 object_writer.write::<_, _, 4>(&prepared_custom_metadata);
154 }
155 if let ::core::option::Option::Some(prepared_version) =
156 prepared_version
157 {
158 object_writer.write::<_, _, 2>(&prepared_version);
159 }
160 });
161 }
162 builder.current_offset()
163 }
164 }
165
166 impl ::planus::WriteAs<::planus::Offset<Footer>> for Footer {
167 type Prepared = ::planus::Offset<Self>;
168
169 #[inline]
170 fn prepare(
171 &self,
172 builder: &mut ::planus::Builder,
173 ) -> ::planus::Offset<Footer> {
174 ::planus::WriteAsOffset::prepare(self, builder)
175 }
176 }
177
178 impl ::planus::WriteAsOptional<::planus::Offset<Footer>> for Footer {
179 type Prepared = ::planus::Offset<Self>;
180
181 #[inline]
182 fn prepare(
183 &self,
184 builder: &mut ::planus::Builder,
185 ) -> ::core::option::Option<::planus::Offset<Footer>>
186 {
187 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
188 self, builder,
189 ))
190 }
191 }
192
193 impl ::planus::WriteAsOffset<Footer> for Footer {
194 #[inline]
195 fn prepare(
196 &self,
197 builder: &mut ::planus::Builder,
198 ) -> ::planus::Offset<Footer> {
199 Footer::create(
200 builder,
201 self.version,
202 &self.schema,
203 &self.dictionaries,
204 &self.record_batches,
205 &self.custom_metadata,
206 )
207 }
208 }
209
210 /// Builder for serializing an instance of the [Footer] type.
211 ///
212 /// Can be created using the [Footer::builder] method.
213 #[derive(Debug)]
214 #[must_use]
215 pub struct FooterBuilder<State>(State);
216
217 impl FooterBuilder<()> {
218 /// Setter for the [`version` field](Footer#structfield.version).
219 #[inline]
220 #[allow(clippy::type_complexity)]
221 pub fn version<T0>(self, value: T0) -> FooterBuilder<(T0,)>
222 where
223 T0: ::planus::WriteAsDefault<
224 self::MetadataVersion,
225 self::MetadataVersion,
226 >,
227 {
228 FooterBuilder((value,))
229 }
230
231 /// Sets the [`version` field](Footer#structfield.version) to the default value.
232 #[inline]
233 #[allow(clippy::type_complexity)]
234 pub fn version_as_default(
235 self,
236 ) -> FooterBuilder<(::planus::DefaultValue,)> {
237 self.version(::planus::DefaultValue)
238 }
239 }
240
241 impl<T0> FooterBuilder<(T0,)> {
242 /// Setter for the [`schema` field](Footer#structfield.schema).
243 #[inline]
244 #[allow(clippy::type_complexity)]
245 pub fn schema<T1>(self, value: T1) -> FooterBuilder<(T0, T1)>
246 where
247 T1: ::planus::WriteAsOptional<::planus::Offset<self::Schema>>,
248 {
249 let (v0,) = self.0;
250 FooterBuilder((v0, value))
251 }
252
253 /// Sets the [`schema` field](Footer#structfield.schema) to null.
254 #[inline]
255 #[allow(clippy::type_complexity)]
256 pub fn schema_as_null(self) -> FooterBuilder<(T0, ())> {
257 self.schema(())
258 }
259 }
260
261 impl<T0, T1> FooterBuilder<(T0, T1)> {
262 /// Setter for the [`dictionaries` field](Footer#structfield.dictionaries).
263 #[inline]
264 #[allow(clippy::type_complexity)]
265 pub fn dictionaries<T2>(self, value: T2) -> FooterBuilder<(T0, T1, T2)>
266 where
267 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
268 {
269 let (v0, v1) = self.0;
270 FooterBuilder((v0, v1, value))
271 }
272
273 /// Sets the [`dictionaries` field](Footer#structfield.dictionaries) to null.
274 #[inline]
275 #[allow(clippy::type_complexity)]
276 pub fn dictionaries_as_null(self) -> FooterBuilder<(T0, T1, ())> {
277 self.dictionaries(())
278 }
279 }
280
281 impl<T0, T1, T2> FooterBuilder<(T0, T1, T2)> {
282 /// Setter for the [`recordBatches` field](Footer#structfield.record_batches).
283 #[inline]
284 #[allow(clippy::type_complexity)]
285 pub fn record_batches<T3>(
286 self,
287 value: T3,
288 ) -> FooterBuilder<(T0, T1, T2, T3)>
289 where
290 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
291 {
292 let (v0, v1, v2) = self.0;
293 FooterBuilder((v0, v1, v2, value))
294 }
295
296 /// Sets the [`recordBatches` field](Footer#structfield.record_batches) to null.
297 #[inline]
298 #[allow(clippy::type_complexity)]
299 pub fn record_batches_as_null(self) -> FooterBuilder<(T0, T1, T2, ())> {
300 self.record_batches(())
301 }
302 }
303
304 impl<T0, T1, T2, T3> FooterBuilder<(T0, T1, T2, T3)> {
305 /// Setter for the [`custom_metadata` field](Footer#structfield.custom_metadata).
306 #[inline]
307 #[allow(clippy::type_complexity)]
308 pub fn custom_metadata<T4>(
309 self,
310 value: T4,
311 ) -> FooterBuilder<(T0, T1, T2, T3, T4)>
312 where
313 T4: ::planus::WriteAsOptional<
314 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
315 >,
316 {
317 let (v0, v1, v2, v3) = self.0;
318 FooterBuilder((v0, v1, v2, v3, value))
319 }
320
321 /// Sets the [`custom_metadata` field](Footer#structfield.custom_metadata) to null.
322 #[inline]
323 #[allow(clippy::type_complexity)]
324 pub fn custom_metadata_as_null(
325 self,
326 ) -> FooterBuilder<(T0, T1, T2, T3, ())> {
327 self.custom_metadata(())
328 }
329 }
330
331 impl<T0, T1, T2, T3, T4> FooterBuilder<(T0, T1, T2, T3, T4)> {
332 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Footer].
333 #[inline]
334 pub fn finish(
335 self,
336 builder: &mut ::planus::Builder,
337 ) -> ::planus::Offset<Footer>
338 where
339 Self: ::planus::WriteAsOffset<Footer>,
340 {
341 ::planus::WriteAsOffset::prepare(&self, builder)
342 }
343 }
344
345 impl<
346 T0: ::planus::WriteAsDefault<self::MetadataVersion, self::MetadataVersion>,
347 T1: ::planus::WriteAsOptional<::planus::Offset<self::Schema>>,
348 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
349 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
350 T4: ::planus::WriteAsOptional<
351 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
352 >,
353 > ::planus::WriteAs<::planus::Offset<Footer>>
354 for FooterBuilder<(T0, T1, T2, T3, T4)>
355 {
356 type Prepared = ::planus::Offset<Footer>;
357
358 #[inline]
359 fn prepare(
360 &self,
361 builder: &mut ::planus::Builder,
362 ) -> ::planus::Offset<Footer> {
363 ::planus::WriteAsOffset::prepare(self, builder)
364 }
365 }
366
367 impl<
368 T0: ::planus::WriteAsDefault<self::MetadataVersion, self::MetadataVersion>,
369 T1: ::planus::WriteAsOptional<::planus::Offset<self::Schema>>,
370 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
371 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
372 T4: ::planus::WriteAsOptional<
373 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
374 >,
375 > ::planus::WriteAsOptional<::planus::Offset<Footer>>
376 for FooterBuilder<(T0, T1, T2, T3, T4)>
377 {
378 type Prepared = ::planus::Offset<Footer>;
379
380 #[inline]
381 fn prepare(
382 &self,
383 builder: &mut ::planus::Builder,
384 ) -> ::core::option::Option<::planus::Offset<Footer>>
385 {
386 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
387 self, builder,
388 ))
389 }
390 }
391
392 impl<
393 T0: ::planus::WriteAsDefault<self::MetadataVersion, self::MetadataVersion>,
394 T1: ::planus::WriteAsOptional<::planus::Offset<self::Schema>>,
395 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
396 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Block]>>,
397 T4: ::planus::WriteAsOptional<
398 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
399 >,
400 > ::planus::WriteAsOffset<Footer> for FooterBuilder<(T0, T1, T2, T3, T4)>
401 {
402 #[inline]
403 fn prepare(
404 &self,
405 builder: &mut ::planus::Builder,
406 ) -> ::planus::Offset<Footer> {
407 let (v0, v1, v2, v3, v4) = &self.0;
408 Footer::create(builder, v0, v1, v2, v3, v4)
409 }
410 }
411
412 /// Reference to a deserialized [Footer].
413 #[derive(Copy, Clone)]
414 pub struct FooterRef<'a>(::planus::table_reader::Table<'a>);
415
416 impl<'a> FooterRef<'a> {
417 /// Getter for the [`version` field](Footer#structfield.version).
418 #[inline]
419 pub fn version(&self) -> ::planus::Result<self::MetadataVersion> {
420 ::core::result::Result::Ok(
421 self.0
422 .access(0, "Footer", "version")?
423 .unwrap_or(self::MetadataVersion::V1),
424 )
425 }
426
427 /// Getter for the [`schema` field](Footer#structfield.schema).
428 #[inline]
429 pub fn schema(
430 &self,
431 ) -> ::planus::Result<::core::option::Option<self::SchemaRef<'a>>>
432 {
433 self.0.access(1, "Footer", "schema")
434 }
435
436 /// Getter for the [`dictionaries` field](Footer#structfield.dictionaries).
437 #[inline]
438 pub fn dictionaries(
439 &self,
440 ) -> ::planus::Result<
441 ::core::option::Option<::planus::Vector<'a, self::BlockRef<'a>>>,
442 > {
443 self.0.access(2, "Footer", "dictionaries")
444 }
445
446 /// Getter for the [`recordBatches` field](Footer#structfield.record_batches).
447 #[inline]
448 pub fn record_batches(
449 &self,
450 ) -> ::planus::Result<
451 ::core::option::Option<::planus::Vector<'a, self::BlockRef<'a>>>,
452 > {
453 self.0.access(3, "Footer", "record_batches")
454 }
455
456 /// Getter for the [`custom_metadata` field](Footer#structfield.custom_metadata).
457 #[inline]
458 pub fn custom_metadata(
459 &self,
460 ) -> ::planus::Result<
461 ::core::option::Option<
462 ::planus::Vector<'a, ::planus::Result<self::KeyValueRef<'a>>>,
463 >,
464 > {
465 self.0.access(4, "Footer", "custom_metadata")
466 }
467 }
468
469 impl<'a> ::core::fmt::Debug for FooterRef<'a> {
470 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
471 let mut f = f.debug_struct("FooterRef");
472 f.field("version", &self.version());
473 if let ::core::option::Option::Some(field_schema) =
474 self.schema().transpose()
475 {
476 f.field("schema", &field_schema);
477 }
478 if let ::core::option::Option::Some(field_dictionaries) =
479 self.dictionaries().transpose()
480 {
481 f.field("dictionaries", &field_dictionaries);
482 }
483 if let ::core::option::Option::Some(field_record_batches) =
484 self.record_batches().transpose()
485 {
486 f.field("record_batches", &field_record_batches);
487 }
488 if let ::core::option::Option::Some(field_custom_metadata) =
489 self.custom_metadata().transpose()
490 {
491 f.field("custom_metadata", &field_custom_metadata);
492 }
493 f.finish()
494 }
495 }
496
497 impl<'a> ::core::convert::TryFrom<FooterRef<'a>> for Footer {
498 type Error = ::planus::Error;
499
500 #[allow(unreachable_code)]
501 fn try_from(value: FooterRef<'a>) -> ::planus::Result<Self> {
502 ::core::result::Result::Ok(Self {
503 version: ::core::convert::TryInto::try_into(value.version()?)?,
504 schema: if let ::core::option::Option::Some(schema) =
505 value.schema()?
506 {
507 ::core::option::Option::Some(::planus::alloc::boxed::Box::new(
508 ::core::convert::TryInto::try_into(schema)?,
509 ))
510 } else {
511 ::core::option::Option::None
512 },
513 dictionaries: if let ::core::option::Option::Some(dictionaries) =
514 value.dictionaries()?
515 {
516 ::core::option::Option::Some(dictionaries.to_vec()?)
517 } else {
518 ::core::option::Option::None
519 },
520 record_batches: if let ::core::option::Option::Some(
521 record_batches,
522 ) = value.record_batches()?
523 {
524 ::core::option::Option::Some(record_batches.to_vec()?)
525 } else {
526 ::core::option::Option::None
527 },
528 custom_metadata: if let ::core::option::Option::Some(
529 custom_metadata,
530 ) = value.custom_metadata()?
531 {
532 ::core::option::Option::Some(custom_metadata.to_vec_result()?)
533 } else {
534 ::core::option::Option::None
535 },
536 })
537 }
538 }
539
540 impl<'a> ::planus::TableRead<'a> for FooterRef<'a> {
541 #[inline]
542 fn from_buffer(
543 buffer: ::planus::SliceWithStartOffset<'a>,
544 offset: usize,
545 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
546 {
547 ::core::result::Result::Ok(Self(
548 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
549 ))
550 }
551 }
552
553 impl<'a> ::planus::VectorReadInner<'a> for FooterRef<'a> {
554 type Error = ::planus::Error;
555 const STRIDE: usize = 4;
556
557 unsafe fn from_buffer(
558 buffer: ::planus::SliceWithStartOffset<'a>,
559 offset: usize,
560 ) -> ::planus::Result<Self> {
561 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
562 error_kind.with_error_location(
563 "[FooterRef]",
564 "get",
565 buffer.offset_from_start,
566 )
567 })
568 }
569 }
570
571 /// # Safety
572 /// The planus compiler generates implementations that initialize
573 /// the bytes in `write_values`.
574 unsafe impl ::planus::VectorWrite<::planus::Offset<Footer>> for Footer {
575 type Value = ::planus::Offset<Footer>;
576 const STRIDE: usize = 4;
577 #[inline]
578 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
579 ::planus::WriteAs::prepare(self, builder)
580 }
581
582 #[inline]
583 unsafe fn write_values(
584 values: &[::planus::Offset<Footer>],
585 bytes: *mut ::core::mem::MaybeUninit<u8>,
586 buffer_position: u32,
587 ) {
588 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
589 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
590 ::planus::WriteAsPrimitive::write(
591 v,
592 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
593 buffer_position - (Self::STRIDE * i) as u32,
594 );
595 }
596 }
597 }
598
599 impl<'a> ::planus::ReadAsRoot<'a> for FooterRef<'a> {
600 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
601 ::planus::TableRead::from_buffer(
602 ::planus::SliceWithStartOffset {
603 buffer: slice,
604 offset_from_start: 0,
605 },
606 0,
607 )
608 .map_err(|error_kind| {
609 error_kind.with_error_location("[FooterRef]", "read_as_root", 0)
610 })
611 }
612 }
613
614 /// The struct `Block` in the namespace `org.apache.arrow.flatbuf`
615 ///
616 /// Generated from these locations:
617 /// * Struct `Block` in the file `File.fbs:39`
618 #[derive(
619 Copy,
620 Clone,
621 Debug,
622 PartialEq,
623 PartialOrd,
624 Eq,
625 Ord,
626 Hash,
627 Default,
628 ::serde::Serialize,
629 ::serde::Deserialize,
630 )]
631 pub struct Block {
632 /// Index to the start of the RecordBlock (note this is past the Message header)
633 pub offset: i64,
634
635 /// Length of the metadata
636 pub meta_data_length: i32,
637
638 /// Length of the data (this is aligned so there can be a gap between this and
639 /// the metadata).
640 pub body_length: i64,
641 }
642
643 /// # Safety
644 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
645 unsafe impl ::planus::Primitive for Block {
646 const ALIGNMENT: usize = 8;
647 const SIZE: usize = 24;
648 }
649
650 #[allow(clippy::identity_op)]
651 impl ::planus::WriteAsPrimitive<Block> for Block {
652 #[inline]
653 fn write<const N: usize>(
654 &self,
655 cursor: ::planus::Cursor<'_, N>,
656 buffer_position: u32,
657 ) {
658 let (cur, cursor) = cursor.split::<8, 16>();
659 self.offset.write(cur, buffer_position - 0);
660 let (cur, cursor) = cursor.split::<4, 12>();
661 self.meta_data_length.write(cur, buffer_position - 8);
662 let cursor = cursor.write::<4, 8>([0; 4]);
663 let (cur, cursor) = cursor.split::<8, 0>();
664 self.body_length.write(cur, buffer_position - 16);
665 cursor.finish([]);
666 }
667 }
668
669 impl ::planus::WriteAsOffset<Block> for Block {
670 #[inline]
671 fn prepare(
672 &self,
673 builder: &mut ::planus::Builder,
674 ) -> ::planus::Offset<Block> {
675 unsafe {
676 builder.write_with(24, 7, |buffer_position, bytes| {
677 let bytes = bytes.as_mut_ptr();
678
679 ::planus::WriteAsPrimitive::write(
680 self,
681 ::planus::Cursor::new(
682 &mut *(bytes
683 as *mut [::core::mem::MaybeUninit<u8>; 24]),
684 ),
685 buffer_position,
686 );
687 });
688 }
689 builder.current_offset()
690 }
691 }
692
693 impl ::planus::WriteAs<Block> for Block {
694 type Prepared = Self;
695 #[inline]
696 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
697 *self
698 }
699 }
700
701 impl ::planus::WriteAsOptional<Block> for Block {
702 type Prepared = Self;
703 #[inline]
704 fn prepare(
705 &self,
706 _builder: &mut ::planus::Builder,
707 ) -> ::core::option::Option<Self> {
708 ::core::option::Option::Some(*self)
709 }
710 }
711
712 /// Reference to a deserialized [Block].
713 #[derive(Copy, Clone)]
714 pub struct BlockRef<'a>(::planus::ArrayWithStartOffset<'a, 24>);
715
716 impl<'a> BlockRef<'a> {
717 /// Getter for the [`offset` field](Block#structfield.offset).
718 pub fn offset(&self) -> i64 {
719 let buffer = self.0.advance_as_array::<8>(0).unwrap();
720
721 i64::from_le_bytes(*buffer.as_array())
722 }
723
724 /// Getter for the [`metaDataLength` field](Block#structfield.meta_data_length).
725 pub fn meta_data_length(&self) -> i32 {
726 let buffer = self.0.advance_as_array::<4>(8).unwrap();
727
728 i32::from_le_bytes(*buffer.as_array())
729 }
730
731 /// Getter for the [`bodyLength` field](Block#structfield.body_length).
732 pub fn body_length(&self) -> i64 {
733 let buffer = self.0.advance_as_array::<8>(16).unwrap();
734
735 i64::from_le_bytes(*buffer.as_array())
736 }
737 }
738
739 impl<'a> ::core::fmt::Debug for BlockRef<'a> {
740 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
741 let mut f = f.debug_struct("BlockRef");
742 f.field("offset", &self.offset());
743 f.field("meta_data_length", &self.meta_data_length());
744 f.field("body_length", &self.body_length());
745 f.finish()
746 }
747 }
748
749 impl<'a> ::core::convert::From<::planus::ArrayWithStartOffset<'a, 24>> for BlockRef<'a> {
750 fn from(array: ::planus::ArrayWithStartOffset<'a, 24>) -> Self {
751 Self(array)
752 }
753 }
754
755 impl<'a> ::core::convert::From<BlockRef<'a>> for Block {
756 #[allow(unreachable_code)]
757 fn from(value: BlockRef<'a>) -> Self {
758 Self {
759 offset: value.offset(),
760 meta_data_length: value.meta_data_length(),
761 body_length: value.body_length(),
762 }
763 }
764 }
765
766 impl<'a, 'b> ::core::cmp::PartialEq<BlockRef<'a>> for BlockRef<'b> {
767 fn eq(&self, other: &BlockRef<'_>) -> bool {
768 self.offset() == other.offset()
769 && self.meta_data_length() == other.meta_data_length()
770 && self.body_length() == other.body_length()
771 }
772 }
773
774 impl<'a> ::core::cmp::Eq for BlockRef<'a> {}
775 impl<'a, 'b> ::core::cmp::PartialOrd<BlockRef<'a>> for BlockRef<'b> {
776 fn partial_cmp(
777 &self,
778 other: &BlockRef<'_>,
779 ) -> ::core::option::Option<::core::cmp::Ordering> {
780 ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
781 }
782 }
783
784 impl<'a> ::core::cmp::Ord for BlockRef<'a> {
785 fn cmp(&self, other: &BlockRef<'_>) -> ::core::cmp::Ordering {
786 self.offset()
787 .cmp(&other.offset())
788 .then_with(|| {
789 self.meta_data_length().cmp(&other.meta_data_length())
790 })
791 .then_with(|| self.body_length().cmp(&other.body_length()))
792 }
793 }
794
795 impl<'a> ::core::hash::Hash for BlockRef<'a> {
796 fn hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
797 self.offset().hash(state);
798 self.meta_data_length().hash(state);
799 self.body_length().hash(state);
800 }
801 }
802
803 impl<'a> ::planus::TableRead<'a> for BlockRef<'a> {
804 #[inline]
805 fn from_buffer(
806 buffer: ::planus::SliceWithStartOffset<'a>,
807 offset: usize,
808 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
809 {
810 let buffer = buffer.advance_as_array::<24>(offset)?;
811 ::core::result::Result::Ok(Self(buffer))
812 }
813 }
814
815 impl<'a> ::planus::VectorRead<'a> for BlockRef<'a> {
816 const STRIDE: usize = 24;
817
818 #[inline]
819 unsafe fn from_buffer(
820 buffer: ::planus::SliceWithStartOffset<'a>,
821 offset: usize,
822 ) -> Self {
823 Self(unsafe { buffer.unchecked_advance_as_array(offset) })
824 }
825 }
826
827 /// # Safety
828 /// The planus compiler generates implementations that initialize
829 /// the bytes in `write_values`.
830 unsafe impl ::planus::VectorWrite<Block> for Block {
831 const STRIDE: usize = 24;
832
833 type Value = Block;
834
835 #[inline]
836 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self::Value {
837 *self
838 }
839
840 #[inline]
841 unsafe fn write_values(
842 values: &[Block],
843 bytes: *mut ::core::mem::MaybeUninit<u8>,
844 buffer_position: u32,
845 ) {
846 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 24];
847 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
848 ::planus::WriteAsPrimitive::write(
849 v,
850 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
851 buffer_position - (24 * i) as u32,
852 );
853 }
854 }
855 }
856
857 /// The enum `MetadataVersion` in the namespace `org.apache.arrow.flatbuf`
858 ///
859 /// Generated from these locations:
860 /// * Enum `MetadataVersion` in the file `Schema.fbs:31`
861 #[derive(
862 Copy,
863 Clone,
864 Debug,
865 PartialEq,
866 Eq,
867 PartialOrd,
868 Ord,
869 Hash,
870 ::serde::Serialize,
871 ::serde::Deserialize,
872 )]
873 #[repr(i16)]
874 pub enum MetadataVersion {
875 /// 0.1.0 (October 2016).
876 V1 = 0,
877
878 /// 0.2.0 (February 2017). Non-backwards compatible with V1.
879 V2 = 1,
880
881 /// 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2.
882 V3 = 2,
883
884 /// >= 0.8.0 (December 2017). Non-backwards compatible with V3.
885 V4 = 3,
886
887 /// >= 1.0.0 (July 2020). Backwards compatible with V4 (V5 readers can read V4
888 /// metadata and IPC messages). Implementations are recommended to provide a
889 /// V4 compatibility mode with V5 format changes disabled.
890 ///
891 /// Incompatible changes between V4 and V5:
892 /// - Union buffer layout has changed. In V5, Unions don't have a validity
893 /// bitmap buffer.
894 V5 = 4,
895 }
896
897 impl MetadataVersion {
898 /// Array containing all valid variants of MetadataVersion
899 pub const ENUM_VALUES: [Self; 5] =
900 [Self::V1, Self::V2, Self::V3, Self::V4, Self::V5];
901 }
902
903 impl ::core::convert::TryFrom<i16> for MetadataVersion {
904 type Error = ::planus::errors::UnknownEnumTagKind;
905 #[inline]
906 fn try_from(
907 value: i16,
908 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
909 {
910 #[allow(clippy::match_single_binding)]
911 match value {
912 0 => ::core::result::Result::Ok(MetadataVersion::V1),
913 1 => ::core::result::Result::Ok(MetadataVersion::V2),
914 2 => ::core::result::Result::Ok(MetadataVersion::V3),
915 3 => ::core::result::Result::Ok(MetadataVersion::V4),
916 4 => ::core::result::Result::Ok(MetadataVersion::V5),
917
918 _ => ::core::result::Result::Err(
919 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
920 ),
921 }
922 }
923 }
924
925 impl ::core::convert::From<MetadataVersion> for i16 {
926 #[inline]
927 fn from(value: MetadataVersion) -> Self {
928 value as i16
929 }
930 }
931
932 /// # Safety
933 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
934 unsafe impl ::planus::Primitive for MetadataVersion {
935 const ALIGNMENT: usize = 2;
936 const SIZE: usize = 2;
937 }
938
939 impl ::planus::WriteAsPrimitive<MetadataVersion> for MetadataVersion {
940 #[inline]
941 fn write<const N: usize>(
942 &self,
943 cursor: ::planus::Cursor<'_, N>,
944 buffer_position: u32,
945 ) {
946 (*self as i16).write(cursor, buffer_position);
947 }
948 }
949
950 impl ::planus::WriteAs<MetadataVersion> for MetadataVersion {
951 type Prepared = Self;
952
953 #[inline]
954 fn prepare(&self, _builder: &mut ::planus::Builder) -> MetadataVersion {
955 *self
956 }
957 }
958
959 impl ::planus::WriteAsDefault<MetadataVersion, MetadataVersion> for MetadataVersion {
960 type Prepared = Self;
961
962 #[inline]
963 fn prepare(
964 &self,
965 _builder: &mut ::planus::Builder,
966 default: &MetadataVersion,
967 ) -> ::core::option::Option<MetadataVersion> {
968 if self == default {
969 ::core::option::Option::None
970 } else {
971 ::core::option::Option::Some(*self)
972 }
973 }
974 }
975
976 impl ::planus::WriteAsOptional<MetadataVersion> for MetadataVersion {
977 type Prepared = Self;
978
979 #[inline]
980 fn prepare(
981 &self,
982 _builder: &mut ::planus::Builder,
983 ) -> ::core::option::Option<MetadataVersion> {
984 ::core::option::Option::Some(*self)
985 }
986 }
987
988 impl<'buf> ::planus::TableRead<'buf> for MetadataVersion {
989 #[inline]
990 fn from_buffer(
991 buffer: ::planus::SliceWithStartOffset<'buf>,
992 offset: usize,
993 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
994 {
995 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
996 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
997 }
998 }
999
1000 impl<'buf> ::planus::VectorReadInner<'buf> for MetadataVersion {
1001 type Error = ::planus::errors::UnknownEnumTag;
1002 const STRIDE: usize = 2;
1003 #[inline]
1004 unsafe fn from_buffer(
1005 buffer: ::planus::SliceWithStartOffset<'buf>,
1006 offset: usize,
1007 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
1008 {
1009 let value = unsafe {
1010 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
1011 };
1012 let value: ::core::result::Result<Self, _> =
1013 ::core::convert::TryInto::try_into(value);
1014 value.map_err(|error_kind| {
1015 error_kind.with_error_location(
1016 "MetadataVersion",
1017 "VectorRead::from_buffer",
1018 buffer.offset_from_start,
1019 )
1020 })
1021 }
1022 }
1023
1024 /// # Safety
1025 /// The planus compiler generates implementations that initialize
1026 /// the bytes in `write_values`.
1027 unsafe impl ::planus::VectorWrite<MetadataVersion> for MetadataVersion {
1028 const STRIDE: usize = 2;
1029
1030 type Value = Self;
1031
1032 #[inline]
1033 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
1034 *self
1035 }
1036
1037 #[inline]
1038 unsafe fn write_values(
1039 values: &[Self],
1040 bytes: *mut ::core::mem::MaybeUninit<u8>,
1041 buffer_position: u32,
1042 ) {
1043 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
1044 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
1045 ::planus::WriteAsPrimitive::write(
1046 v,
1047 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
1048 buffer_position - (2 * i) as u32,
1049 );
1050 }
1051 }
1052 }
1053
1054 /// Represents Arrow Features that might not have full support
1055 /// within implementations. This is intended to be used in
1056 /// two scenarios:
1057 /// 1. A mechanism for readers of Arrow Streams
1058 /// and files to understand that the stream or file makes
1059 /// use of a feature that isn't supported or unknown to
1060 /// the implementation (and therefore can meet the Arrow
1061 /// forward compatibility guarantees).
1062 /// 2. A means of negotiating between a client and server
1063 /// what features a stream is allowed to use. The enums
1064 /// values here are intended to represent higher level
1065 /// features, additional details may be negotiated
1066 /// with key-value pairs specific to the protocol.
1067 ///
1068 /// Enums added to this list should be assigned power-of-two values
1069 /// to facilitate exchanging and comparing bitmaps for supported
1070 /// features.
1071 ///
1072 /// Generated from these locations:
1073 /// * Enum `Feature` in the file `Schema.fbs:71`
1074 #[derive(
1075 Copy,
1076 Clone,
1077 Debug,
1078 PartialEq,
1079 Eq,
1080 PartialOrd,
1081 Ord,
1082 Hash,
1083 ::serde::Serialize,
1084 ::serde::Deserialize,
1085 )]
1086 #[repr(i64)]
1087 pub enum Feature {
1088 /// Needed to make flatbuffers happy.
1089 Unused = 0,
1090
1091 /// The stream makes use of multiple full dictionaries with the
1092 /// same ID and assumes clients implement dictionary replacement
1093 /// correctly.
1094 DictionaryReplacement = 1,
1095
1096 /// The stream makes use of compressed bodies as described
1097 /// in Message.fbs.
1098 CompressedBody = 2,
1099 }
1100
1101 impl Feature {
1102 /// Array containing all valid variants of Feature
1103 pub const ENUM_VALUES: [Self; 3] = [
1104 Self::Unused,
1105 Self::DictionaryReplacement,
1106 Self::CompressedBody,
1107 ];
1108 }
1109
1110 impl ::core::convert::TryFrom<i64> for Feature {
1111 type Error = ::planus::errors::UnknownEnumTagKind;
1112 #[inline]
1113 fn try_from(
1114 value: i64,
1115 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
1116 {
1117 #[allow(clippy::match_single_binding)]
1118 match value {
1119 0 => ::core::result::Result::Ok(Feature::Unused),
1120 1 => ::core::result::Result::Ok(Feature::DictionaryReplacement),
1121 2 => ::core::result::Result::Ok(Feature::CompressedBody),
1122
1123 _ => ::core::result::Result::Err(
1124 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
1125 ),
1126 }
1127 }
1128 }
1129
1130 impl ::core::convert::From<Feature> for i64 {
1131 #[inline]
1132 fn from(value: Feature) -> Self {
1133 value as i64
1134 }
1135 }
1136
1137 /// # Safety
1138 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
1139 unsafe impl ::planus::Primitive for Feature {
1140 const ALIGNMENT: usize = 8;
1141 const SIZE: usize = 8;
1142 }
1143
1144 impl ::planus::WriteAsPrimitive<Feature> for Feature {
1145 #[inline]
1146 fn write<const N: usize>(
1147 &self,
1148 cursor: ::planus::Cursor<'_, N>,
1149 buffer_position: u32,
1150 ) {
1151 (*self as i64).write(cursor, buffer_position);
1152 }
1153 }
1154
1155 impl ::planus::WriteAs<Feature> for Feature {
1156 type Prepared = Self;
1157
1158 #[inline]
1159 fn prepare(&self, _builder: &mut ::planus::Builder) -> Feature {
1160 *self
1161 }
1162 }
1163
1164 impl ::planus::WriteAsDefault<Feature, Feature> for Feature {
1165 type Prepared = Self;
1166
1167 #[inline]
1168 fn prepare(
1169 &self,
1170 _builder: &mut ::planus::Builder,
1171 default: &Feature,
1172 ) -> ::core::option::Option<Feature> {
1173 if self == default {
1174 ::core::option::Option::None
1175 } else {
1176 ::core::option::Option::Some(*self)
1177 }
1178 }
1179 }
1180
1181 impl ::planus::WriteAsOptional<Feature> for Feature {
1182 type Prepared = Self;
1183
1184 #[inline]
1185 fn prepare(
1186 &self,
1187 _builder: &mut ::planus::Builder,
1188 ) -> ::core::option::Option<Feature> {
1189 ::core::option::Option::Some(*self)
1190 }
1191 }
1192
1193 impl<'buf> ::planus::TableRead<'buf> for Feature {
1194 #[inline]
1195 fn from_buffer(
1196 buffer: ::planus::SliceWithStartOffset<'buf>,
1197 offset: usize,
1198 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
1199 {
1200 let n: i64 = ::planus::TableRead::from_buffer(buffer, offset)?;
1201 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
1202 }
1203 }
1204
1205 impl<'buf> ::planus::VectorReadInner<'buf> for Feature {
1206 type Error = ::planus::errors::UnknownEnumTag;
1207 const STRIDE: usize = 8;
1208 #[inline]
1209 unsafe fn from_buffer(
1210 buffer: ::planus::SliceWithStartOffset<'buf>,
1211 offset: usize,
1212 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
1213 {
1214 let value = unsafe {
1215 <i64 as ::planus::VectorRead>::from_buffer(buffer, offset)
1216 };
1217 let value: ::core::result::Result<Self, _> =
1218 ::core::convert::TryInto::try_into(value);
1219 value.map_err(|error_kind| {
1220 error_kind.with_error_location(
1221 "Feature",
1222 "VectorRead::from_buffer",
1223 buffer.offset_from_start,
1224 )
1225 })
1226 }
1227 }
1228
1229 /// # Safety
1230 /// The planus compiler generates implementations that initialize
1231 /// the bytes in `write_values`.
1232 unsafe impl ::planus::VectorWrite<Feature> for Feature {
1233 const STRIDE: usize = 8;
1234
1235 type Value = Self;
1236
1237 #[inline]
1238 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
1239 *self
1240 }
1241
1242 #[inline]
1243 unsafe fn write_values(
1244 values: &[Self],
1245 bytes: *mut ::core::mem::MaybeUninit<u8>,
1246 buffer_position: u32,
1247 ) {
1248 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 8];
1249 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
1250 ::planus::WriteAsPrimitive::write(
1251 v,
1252 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
1253 buffer_position - (8 * i) as u32,
1254 );
1255 }
1256 }
1257 }
1258
1259 /// These are stored in the flatbuffer in the Type union below
1260 ///
1261 /// Generated from these locations:
1262 /// * Table `Null` in the file `Schema.fbs:85`
1263 #[derive(
1264 Clone,
1265 Debug,
1266 PartialEq,
1267 PartialOrd,
1268 Eq,
1269 Ord,
1270 Hash,
1271 ::serde::Serialize,
1272 ::serde::Deserialize,
1273 )]
1274 pub struct Null {}
1275
1276 #[allow(clippy::derivable_impls)]
1277 impl ::core::default::Default for Null {
1278 fn default() -> Self {
1279 Self {}
1280 }
1281 }
1282
1283 impl Null {
1284 /// Creates a [NullBuilder] for serializing an instance of this table.
1285 #[inline]
1286 pub fn builder() -> NullBuilder<()> {
1287 NullBuilder(())
1288 }
1289
1290 #[allow(clippy::too_many_arguments)]
1291 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
1292 let table_writer: ::planus::table_writer::TableWriter<4> =
1293 ::core::default::Default::default();
1294 unsafe {
1295 table_writer.finish(builder, |_table_writer| {});
1296 }
1297 builder.current_offset()
1298 }
1299 }
1300
1301 impl ::planus::WriteAs<::planus::Offset<Null>> for Null {
1302 type Prepared = ::planus::Offset<Self>;
1303
1304 #[inline]
1305 fn prepare(
1306 &self,
1307 builder: &mut ::planus::Builder,
1308 ) -> ::planus::Offset<Null> {
1309 ::planus::WriteAsOffset::prepare(self, builder)
1310 }
1311 }
1312
1313 impl ::planus::WriteAsOptional<::planus::Offset<Null>> for Null {
1314 type Prepared = ::planus::Offset<Self>;
1315
1316 #[inline]
1317 fn prepare(
1318 &self,
1319 builder: &mut ::planus::Builder,
1320 ) -> ::core::option::Option<::planus::Offset<Null>>
1321 {
1322 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
1323 self, builder,
1324 ))
1325 }
1326 }
1327
1328 impl ::planus::WriteAsOffset<Null> for Null {
1329 #[inline]
1330 fn prepare(
1331 &self,
1332 builder: &mut ::planus::Builder,
1333 ) -> ::planus::Offset<Null> {
1334 Null::create(builder)
1335 }
1336 }
1337
1338 /// Builder for serializing an instance of the [Null] type.
1339 ///
1340 /// Can be created using the [Null::builder] method.
1341 #[derive(Debug)]
1342 #[must_use]
1343 pub struct NullBuilder<State>(State);
1344
1345 impl NullBuilder<()> {
1346 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Null].
1347 #[inline]
1348 pub fn finish(
1349 self,
1350 builder: &mut ::planus::Builder,
1351 ) -> ::planus::Offset<Null>
1352 where
1353 Self: ::planus::WriteAsOffset<Null>,
1354 {
1355 ::planus::WriteAsOffset::prepare(&self, builder)
1356 }
1357 }
1358
1359 impl ::planus::WriteAs<::planus::Offset<Null>> for NullBuilder<()> {
1360 type Prepared = ::planus::Offset<Null>;
1361
1362 #[inline]
1363 fn prepare(
1364 &self,
1365 builder: &mut ::planus::Builder,
1366 ) -> ::planus::Offset<Null> {
1367 ::planus::WriteAsOffset::prepare(self, builder)
1368 }
1369 }
1370
1371 impl ::planus::WriteAsOptional<::planus::Offset<Null>> for NullBuilder<()> {
1372 type Prepared = ::planus::Offset<Null>;
1373
1374 #[inline]
1375 fn prepare(
1376 &self,
1377 builder: &mut ::planus::Builder,
1378 ) -> ::core::option::Option<::planus::Offset<Null>>
1379 {
1380 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
1381 self, builder,
1382 ))
1383 }
1384 }
1385
1386 impl ::planus::WriteAsOffset<Null> for NullBuilder<()> {
1387 #[inline]
1388 fn prepare(
1389 &self,
1390 builder: &mut ::planus::Builder,
1391 ) -> ::planus::Offset<Null> {
1392 Null::create(builder)
1393 }
1394 }
1395
1396 /// Reference to a deserialized [Null].
1397 #[derive(Copy, Clone)]
1398 pub struct NullRef<'a>(::planus::table_reader::Table<'a>);
1399
1400 impl<'a> NullRef<'a> {}
1401
1402 impl<'a> ::core::fmt::Debug for NullRef<'a> {
1403 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1404 let mut f = f.debug_struct("NullRef");
1405
1406 f.finish()
1407 }
1408 }
1409
1410 impl<'a> ::core::convert::TryFrom<NullRef<'a>> for Null {
1411 type Error = ::planus::Error;
1412
1413 fn try_from(_value: NullRef<'a>) -> ::planus::Result<Self> {
1414 ::core::result::Result::Ok(Self {})
1415 }
1416 }
1417
1418 impl<'a> ::planus::TableRead<'a> for NullRef<'a> {
1419 #[inline]
1420 fn from_buffer(
1421 buffer: ::planus::SliceWithStartOffset<'a>,
1422 offset: usize,
1423 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
1424 {
1425 ::core::result::Result::Ok(Self(
1426 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
1427 ))
1428 }
1429 }
1430
1431 impl<'a> ::planus::VectorReadInner<'a> for NullRef<'a> {
1432 type Error = ::planus::Error;
1433 const STRIDE: usize = 4;
1434
1435 unsafe fn from_buffer(
1436 buffer: ::planus::SliceWithStartOffset<'a>,
1437 offset: usize,
1438 ) -> ::planus::Result<Self> {
1439 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
1440 error_kind.with_error_location(
1441 "[NullRef]",
1442 "get",
1443 buffer.offset_from_start,
1444 )
1445 })
1446 }
1447 }
1448
1449 /// # Safety
1450 /// The planus compiler generates implementations that initialize
1451 /// the bytes in `write_values`.
1452 unsafe impl ::planus::VectorWrite<::planus::Offset<Null>> for Null {
1453 type Value = ::planus::Offset<Null>;
1454 const STRIDE: usize = 4;
1455 #[inline]
1456 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
1457 ::planus::WriteAs::prepare(self, builder)
1458 }
1459
1460 #[inline]
1461 unsafe fn write_values(
1462 values: &[::planus::Offset<Null>],
1463 bytes: *mut ::core::mem::MaybeUninit<u8>,
1464 buffer_position: u32,
1465 ) {
1466 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
1467 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
1468 ::planus::WriteAsPrimitive::write(
1469 v,
1470 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
1471 buffer_position - (Self::STRIDE * i) as u32,
1472 );
1473 }
1474 }
1475 }
1476
1477 impl<'a> ::planus::ReadAsRoot<'a> for NullRef<'a> {
1478 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
1479 ::planus::TableRead::from_buffer(
1480 ::planus::SliceWithStartOffset {
1481 buffer: slice,
1482 offset_from_start: 0,
1483 },
1484 0,
1485 )
1486 .map_err(|error_kind| {
1487 error_kind.with_error_location("[NullRef]", "read_as_root", 0)
1488 })
1489 }
1490 }
1491
1492 /// A Struct_ in the flatbuffer metadata is the same as an Arrow Struct
1493 /// (according to the physical memory layout). We used Struct_ here as
1494 /// Struct is a reserved word in Flatbuffers
1495 ///
1496 /// Generated from these locations:
1497 /// * Table `Struct_` in the file `Schema.fbs:91`
1498 #[derive(
1499 Clone,
1500 Debug,
1501 PartialEq,
1502 PartialOrd,
1503 Eq,
1504 Ord,
1505 Hash,
1506 ::serde::Serialize,
1507 ::serde::Deserialize,
1508 )]
1509 pub struct Struct {}
1510
1511 #[allow(clippy::derivable_impls)]
1512 impl ::core::default::Default for Struct {
1513 fn default() -> Self {
1514 Self {}
1515 }
1516 }
1517
1518 impl Struct {
1519 /// Creates a [StructBuilder] for serializing an instance of this table.
1520 #[inline]
1521 pub fn builder() -> StructBuilder<()> {
1522 StructBuilder(())
1523 }
1524
1525 #[allow(clippy::too_many_arguments)]
1526 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
1527 let table_writer: ::planus::table_writer::TableWriter<4> =
1528 ::core::default::Default::default();
1529 unsafe {
1530 table_writer.finish(builder, |_table_writer| {});
1531 }
1532 builder.current_offset()
1533 }
1534 }
1535
1536 impl ::planus::WriteAs<::planus::Offset<Struct>> for Struct {
1537 type Prepared = ::planus::Offset<Self>;
1538
1539 #[inline]
1540 fn prepare(
1541 &self,
1542 builder: &mut ::planus::Builder,
1543 ) -> ::planus::Offset<Struct> {
1544 ::planus::WriteAsOffset::prepare(self, builder)
1545 }
1546 }
1547
1548 impl ::planus::WriteAsOptional<::planus::Offset<Struct>> for Struct {
1549 type Prepared = ::planus::Offset<Self>;
1550
1551 #[inline]
1552 fn prepare(
1553 &self,
1554 builder: &mut ::planus::Builder,
1555 ) -> ::core::option::Option<::planus::Offset<Struct>>
1556 {
1557 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
1558 self, builder,
1559 ))
1560 }
1561 }
1562
1563 impl ::planus::WriteAsOffset<Struct> for Struct {
1564 #[inline]
1565 fn prepare(
1566 &self,
1567 builder: &mut ::planus::Builder,
1568 ) -> ::planus::Offset<Struct> {
1569 Struct::create(builder)
1570 }
1571 }
1572
1573 /// Builder for serializing an instance of the [Struct] type.
1574 ///
1575 /// Can be created using the [Struct::builder] method.
1576 #[derive(Debug)]
1577 #[must_use]
1578 pub struct StructBuilder<State>(State);
1579
1580 impl StructBuilder<()> {
1581 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Struct].
1582 #[inline]
1583 pub fn finish(
1584 self,
1585 builder: &mut ::planus::Builder,
1586 ) -> ::planus::Offset<Struct>
1587 where
1588 Self: ::planus::WriteAsOffset<Struct>,
1589 {
1590 ::planus::WriteAsOffset::prepare(&self, builder)
1591 }
1592 }
1593
1594 impl ::planus::WriteAs<::planus::Offset<Struct>> for StructBuilder<()> {
1595 type Prepared = ::planus::Offset<Struct>;
1596
1597 #[inline]
1598 fn prepare(
1599 &self,
1600 builder: &mut ::planus::Builder,
1601 ) -> ::planus::Offset<Struct> {
1602 ::planus::WriteAsOffset::prepare(self, builder)
1603 }
1604 }
1605
1606 impl ::planus::WriteAsOptional<::planus::Offset<Struct>> for StructBuilder<()> {
1607 type Prepared = ::planus::Offset<Struct>;
1608
1609 #[inline]
1610 fn prepare(
1611 &self,
1612 builder: &mut ::planus::Builder,
1613 ) -> ::core::option::Option<::planus::Offset<Struct>>
1614 {
1615 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
1616 self, builder,
1617 ))
1618 }
1619 }
1620
1621 impl ::planus::WriteAsOffset<Struct> for StructBuilder<()> {
1622 #[inline]
1623 fn prepare(
1624 &self,
1625 builder: &mut ::planus::Builder,
1626 ) -> ::planus::Offset<Struct> {
1627 Struct::create(builder)
1628 }
1629 }
1630
1631 /// Reference to a deserialized [Struct].
1632 #[derive(Copy, Clone)]
1633 pub struct StructRef<'a>(::planus::table_reader::Table<'a>);
1634
1635 impl<'a> StructRef<'a> {}
1636
1637 impl<'a> ::core::fmt::Debug for StructRef<'a> {
1638 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1639 let mut f = f.debug_struct("StructRef");
1640
1641 f.finish()
1642 }
1643 }
1644
1645 impl<'a> ::core::convert::TryFrom<StructRef<'a>> for Struct {
1646 type Error = ::planus::Error;
1647
1648 fn try_from(_value: StructRef<'a>) -> ::planus::Result<Self> {
1649 ::core::result::Result::Ok(Self {})
1650 }
1651 }
1652
1653 impl<'a> ::planus::TableRead<'a> for StructRef<'a> {
1654 #[inline]
1655 fn from_buffer(
1656 buffer: ::planus::SliceWithStartOffset<'a>,
1657 offset: usize,
1658 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
1659 {
1660 ::core::result::Result::Ok(Self(
1661 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
1662 ))
1663 }
1664 }
1665
1666 impl<'a> ::planus::VectorReadInner<'a> for StructRef<'a> {
1667 type Error = ::planus::Error;
1668 const STRIDE: usize = 4;
1669
1670 unsafe fn from_buffer(
1671 buffer: ::planus::SliceWithStartOffset<'a>,
1672 offset: usize,
1673 ) -> ::planus::Result<Self> {
1674 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
1675 error_kind.with_error_location(
1676 "[StructRef]",
1677 "get",
1678 buffer.offset_from_start,
1679 )
1680 })
1681 }
1682 }
1683
1684 /// # Safety
1685 /// The planus compiler generates implementations that initialize
1686 /// the bytes in `write_values`.
1687 unsafe impl ::planus::VectorWrite<::planus::Offset<Struct>> for Struct {
1688 type Value = ::planus::Offset<Struct>;
1689 const STRIDE: usize = 4;
1690 #[inline]
1691 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
1692 ::planus::WriteAs::prepare(self, builder)
1693 }
1694
1695 #[inline]
1696 unsafe fn write_values(
1697 values: &[::planus::Offset<Struct>],
1698 bytes: *mut ::core::mem::MaybeUninit<u8>,
1699 buffer_position: u32,
1700 ) {
1701 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
1702 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
1703 ::planus::WriteAsPrimitive::write(
1704 v,
1705 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
1706 buffer_position - (Self::STRIDE * i) as u32,
1707 );
1708 }
1709 }
1710 }
1711
1712 impl<'a> ::planus::ReadAsRoot<'a> for StructRef<'a> {
1713 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
1714 ::planus::TableRead::from_buffer(
1715 ::planus::SliceWithStartOffset {
1716 buffer: slice,
1717 offset_from_start: 0,
1718 },
1719 0,
1720 )
1721 .map_err(|error_kind| {
1722 error_kind.with_error_location("[StructRef]", "read_as_root", 0)
1723 })
1724 }
1725 }
1726
1727 /// The table `List` in the namespace `org.apache.arrow.flatbuf`
1728 ///
1729 /// Generated from these locations:
1730 /// * Table `List` in the file `Schema.fbs:94`
1731 #[derive(
1732 Clone,
1733 Debug,
1734 PartialEq,
1735 PartialOrd,
1736 Eq,
1737 Ord,
1738 Hash,
1739 ::serde::Serialize,
1740 ::serde::Deserialize,
1741 )]
1742 pub struct List {}
1743
1744 #[allow(clippy::derivable_impls)]
1745 impl ::core::default::Default for List {
1746 fn default() -> Self {
1747 Self {}
1748 }
1749 }
1750
1751 impl List {
1752 /// Creates a [ListBuilder] for serializing an instance of this table.
1753 #[inline]
1754 pub fn builder() -> ListBuilder<()> {
1755 ListBuilder(())
1756 }
1757
1758 #[allow(clippy::too_many_arguments)]
1759 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
1760 let table_writer: ::planus::table_writer::TableWriter<4> =
1761 ::core::default::Default::default();
1762 unsafe {
1763 table_writer.finish(builder, |_table_writer| {});
1764 }
1765 builder.current_offset()
1766 }
1767 }
1768
1769 impl ::planus::WriteAs<::planus::Offset<List>> for List {
1770 type Prepared = ::planus::Offset<Self>;
1771
1772 #[inline]
1773 fn prepare(
1774 &self,
1775 builder: &mut ::planus::Builder,
1776 ) -> ::planus::Offset<List> {
1777 ::planus::WriteAsOffset::prepare(self, builder)
1778 }
1779 }
1780
1781 impl ::planus::WriteAsOptional<::planus::Offset<List>> for List {
1782 type Prepared = ::planus::Offset<Self>;
1783
1784 #[inline]
1785 fn prepare(
1786 &self,
1787 builder: &mut ::planus::Builder,
1788 ) -> ::core::option::Option<::planus::Offset<List>>
1789 {
1790 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
1791 self, builder,
1792 ))
1793 }
1794 }
1795
1796 impl ::planus::WriteAsOffset<List> for List {
1797 #[inline]
1798 fn prepare(
1799 &self,
1800 builder: &mut ::planus::Builder,
1801 ) -> ::planus::Offset<List> {
1802 List::create(builder)
1803 }
1804 }
1805
1806 /// Builder for serializing an instance of the [List] type.
1807 ///
1808 /// Can be created using the [List::builder] method.
1809 #[derive(Debug)]
1810 #[must_use]
1811 pub struct ListBuilder<State>(State);
1812
1813 impl ListBuilder<()> {
1814 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [List].
1815 #[inline]
1816 pub fn finish(
1817 self,
1818 builder: &mut ::planus::Builder,
1819 ) -> ::planus::Offset<List>
1820 where
1821 Self: ::planus::WriteAsOffset<List>,
1822 {
1823 ::planus::WriteAsOffset::prepare(&self, builder)
1824 }
1825 }
1826
1827 impl ::planus::WriteAs<::planus::Offset<List>> for ListBuilder<()> {
1828 type Prepared = ::planus::Offset<List>;
1829
1830 #[inline]
1831 fn prepare(
1832 &self,
1833 builder: &mut ::planus::Builder,
1834 ) -> ::planus::Offset<List> {
1835 ::planus::WriteAsOffset::prepare(self, builder)
1836 }
1837 }
1838
1839 impl ::planus::WriteAsOptional<::planus::Offset<List>> for ListBuilder<()> {
1840 type Prepared = ::planus::Offset<List>;
1841
1842 #[inline]
1843 fn prepare(
1844 &self,
1845 builder: &mut ::planus::Builder,
1846 ) -> ::core::option::Option<::planus::Offset<List>>
1847 {
1848 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
1849 self, builder,
1850 ))
1851 }
1852 }
1853
1854 impl ::planus::WriteAsOffset<List> for ListBuilder<()> {
1855 #[inline]
1856 fn prepare(
1857 &self,
1858 builder: &mut ::planus::Builder,
1859 ) -> ::planus::Offset<List> {
1860 List::create(builder)
1861 }
1862 }
1863
1864 /// Reference to a deserialized [List].
1865 #[derive(Copy, Clone)]
1866 pub struct ListRef<'a>(::planus::table_reader::Table<'a>);
1867
1868 impl<'a> ListRef<'a> {}
1869
1870 impl<'a> ::core::fmt::Debug for ListRef<'a> {
1871 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1872 let mut f = f.debug_struct("ListRef");
1873
1874 f.finish()
1875 }
1876 }
1877
1878 impl<'a> ::core::convert::TryFrom<ListRef<'a>> for List {
1879 type Error = ::planus::Error;
1880
1881 fn try_from(_value: ListRef<'a>) -> ::planus::Result<Self> {
1882 ::core::result::Result::Ok(Self {})
1883 }
1884 }
1885
1886 impl<'a> ::planus::TableRead<'a> for ListRef<'a> {
1887 #[inline]
1888 fn from_buffer(
1889 buffer: ::planus::SliceWithStartOffset<'a>,
1890 offset: usize,
1891 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
1892 {
1893 ::core::result::Result::Ok(Self(
1894 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
1895 ))
1896 }
1897 }
1898
1899 impl<'a> ::planus::VectorReadInner<'a> for ListRef<'a> {
1900 type Error = ::planus::Error;
1901 const STRIDE: usize = 4;
1902
1903 unsafe fn from_buffer(
1904 buffer: ::planus::SliceWithStartOffset<'a>,
1905 offset: usize,
1906 ) -> ::planus::Result<Self> {
1907 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
1908 error_kind.with_error_location(
1909 "[ListRef]",
1910 "get",
1911 buffer.offset_from_start,
1912 )
1913 })
1914 }
1915 }
1916
1917 /// # Safety
1918 /// The planus compiler generates implementations that initialize
1919 /// the bytes in `write_values`.
1920 unsafe impl ::planus::VectorWrite<::planus::Offset<List>> for List {
1921 type Value = ::planus::Offset<List>;
1922 const STRIDE: usize = 4;
1923 #[inline]
1924 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
1925 ::planus::WriteAs::prepare(self, builder)
1926 }
1927
1928 #[inline]
1929 unsafe fn write_values(
1930 values: &[::planus::Offset<List>],
1931 bytes: *mut ::core::mem::MaybeUninit<u8>,
1932 buffer_position: u32,
1933 ) {
1934 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
1935 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
1936 ::planus::WriteAsPrimitive::write(
1937 v,
1938 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
1939 buffer_position - (Self::STRIDE * i) as u32,
1940 );
1941 }
1942 }
1943 }
1944
1945 impl<'a> ::planus::ReadAsRoot<'a> for ListRef<'a> {
1946 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
1947 ::planus::TableRead::from_buffer(
1948 ::planus::SliceWithStartOffset {
1949 buffer: slice,
1950 offset_from_start: 0,
1951 },
1952 0,
1953 )
1954 .map_err(|error_kind| {
1955 error_kind.with_error_location("[ListRef]", "read_as_root", 0)
1956 })
1957 }
1958 }
1959
1960 /// Same as List, but with 64-bit offsets, allowing to represent
1961 /// extremely large data values.
1962 ///
1963 /// Generated from these locations:
1964 /// * Table `LargeList` in the file `Schema.fbs:99`
1965 #[derive(
1966 Clone,
1967 Debug,
1968 PartialEq,
1969 PartialOrd,
1970 Eq,
1971 Ord,
1972 Hash,
1973 ::serde::Serialize,
1974 ::serde::Deserialize,
1975 )]
1976 pub struct LargeList {}
1977
1978 #[allow(clippy::derivable_impls)]
1979 impl ::core::default::Default for LargeList {
1980 fn default() -> Self {
1981 Self {}
1982 }
1983 }
1984
1985 impl LargeList {
1986 /// Creates a [LargeListBuilder] for serializing an instance of this table.
1987 #[inline]
1988 pub fn builder() -> LargeListBuilder<()> {
1989 LargeListBuilder(())
1990 }
1991
1992 #[allow(clippy::too_many_arguments)]
1993 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
1994 let table_writer: ::planus::table_writer::TableWriter<4> =
1995 ::core::default::Default::default();
1996 unsafe {
1997 table_writer.finish(builder, |_table_writer| {});
1998 }
1999 builder.current_offset()
2000 }
2001 }
2002
2003 impl ::planus::WriteAs<::planus::Offset<LargeList>> for LargeList {
2004 type Prepared = ::planus::Offset<Self>;
2005
2006 #[inline]
2007 fn prepare(
2008 &self,
2009 builder: &mut ::planus::Builder,
2010 ) -> ::planus::Offset<LargeList> {
2011 ::planus::WriteAsOffset::prepare(self, builder)
2012 }
2013 }
2014
2015 impl ::planus::WriteAsOptional<::planus::Offset<LargeList>> for LargeList {
2016 type Prepared = ::planus::Offset<Self>;
2017
2018 #[inline]
2019 fn prepare(
2020 &self,
2021 builder: &mut ::planus::Builder,
2022 ) -> ::core::option::Option<::planus::Offset<LargeList>>
2023 {
2024 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2025 self, builder,
2026 ))
2027 }
2028 }
2029
2030 impl ::planus::WriteAsOffset<LargeList> for LargeList {
2031 #[inline]
2032 fn prepare(
2033 &self,
2034 builder: &mut ::planus::Builder,
2035 ) -> ::planus::Offset<LargeList> {
2036 LargeList::create(builder)
2037 }
2038 }
2039
2040 /// Builder for serializing an instance of the [LargeList] type.
2041 ///
2042 /// Can be created using the [LargeList::builder] method.
2043 #[derive(Debug)]
2044 #[must_use]
2045 pub struct LargeListBuilder<State>(State);
2046
2047 impl LargeListBuilder<()> {
2048 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [LargeList].
2049 #[inline]
2050 pub fn finish(
2051 self,
2052 builder: &mut ::planus::Builder,
2053 ) -> ::planus::Offset<LargeList>
2054 where
2055 Self: ::planus::WriteAsOffset<LargeList>,
2056 {
2057 ::planus::WriteAsOffset::prepare(&self, builder)
2058 }
2059 }
2060
2061 impl ::planus::WriteAs<::planus::Offset<LargeList>> for LargeListBuilder<()> {
2062 type Prepared = ::planus::Offset<LargeList>;
2063
2064 #[inline]
2065 fn prepare(
2066 &self,
2067 builder: &mut ::planus::Builder,
2068 ) -> ::planus::Offset<LargeList> {
2069 ::planus::WriteAsOffset::prepare(self, builder)
2070 }
2071 }
2072
2073 impl ::planus::WriteAsOptional<::planus::Offset<LargeList>> for LargeListBuilder<()> {
2074 type Prepared = ::planus::Offset<LargeList>;
2075
2076 #[inline]
2077 fn prepare(
2078 &self,
2079 builder: &mut ::planus::Builder,
2080 ) -> ::core::option::Option<::planus::Offset<LargeList>>
2081 {
2082 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2083 self, builder,
2084 ))
2085 }
2086 }
2087
2088 impl ::planus::WriteAsOffset<LargeList> for LargeListBuilder<()> {
2089 #[inline]
2090 fn prepare(
2091 &self,
2092 builder: &mut ::planus::Builder,
2093 ) -> ::planus::Offset<LargeList> {
2094 LargeList::create(builder)
2095 }
2096 }
2097
2098 /// Reference to a deserialized [LargeList].
2099 #[derive(Copy, Clone)]
2100 pub struct LargeListRef<'a>(::planus::table_reader::Table<'a>);
2101
2102 impl<'a> LargeListRef<'a> {}
2103
2104 impl<'a> ::core::fmt::Debug for LargeListRef<'a> {
2105 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2106 let mut f = f.debug_struct("LargeListRef");
2107
2108 f.finish()
2109 }
2110 }
2111
2112 impl<'a> ::core::convert::TryFrom<LargeListRef<'a>> for LargeList {
2113 type Error = ::planus::Error;
2114
2115 fn try_from(_value: LargeListRef<'a>) -> ::planus::Result<Self> {
2116 ::core::result::Result::Ok(Self {})
2117 }
2118 }
2119
2120 impl<'a> ::planus::TableRead<'a> for LargeListRef<'a> {
2121 #[inline]
2122 fn from_buffer(
2123 buffer: ::planus::SliceWithStartOffset<'a>,
2124 offset: usize,
2125 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
2126 {
2127 ::core::result::Result::Ok(Self(
2128 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
2129 ))
2130 }
2131 }
2132
2133 impl<'a> ::planus::VectorReadInner<'a> for LargeListRef<'a> {
2134 type Error = ::planus::Error;
2135 const STRIDE: usize = 4;
2136
2137 unsafe fn from_buffer(
2138 buffer: ::planus::SliceWithStartOffset<'a>,
2139 offset: usize,
2140 ) -> ::planus::Result<Self> {
2141 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
2142 error_kind.with_error_location(
2143 "[LargeListRef]",
2144 "get",
2145 buffer.offset_from_start,
2146 )
2147 })
2148 }
2149 }
2150
2151 /// # Safety
2152 /// The planus compiler generates implementations that initialize
2153 /// the bytes in `write_values`.
2154 unsafe impl ::planus::VectorWrite<::planus::Offset<LargeList>> for LargeList {
2155 type Value = ::planus::Offset<LargeList>;
2156 const STRIDE: usize = 4;
2157 #[inline]
2158 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
2159 ::planus::WriteAs::prepare(self, builder)
2160 }
2161
2162 #[inline]
2163 unsafe fn write_values(
2164 values: &[::planus::Offset<LargeList>],
2165 bytes: *mut ::core::mem::MaybeUninit<u8>,
2166 buffer_position: u32,
2167 ) {
2168 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
2169 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
2170 ::planus::WriteAsPrimitive::write(
2171 v,
2172 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
2173 buffer_position - (Self::STRIDE * i) as u32,
2174 );
2175 }
2176 }
2177 }
2178
2179 impl<'a> ::planus::ReadAsRoot<'a> for LargeListRef<'a> {
2180 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
2181 ::planus::TableRead::from_buffer(
2182 ::planus::SliceWithStartOffset {
2183 buffer: slice,
2184 offset_from_start: 0,
2185 },
2186 0,
2187 )
2188 .map_err(|error_kind| {
2189 error_kind.with_error_location("[LargeListRef]", "read_as_root", 0)
2190 })
2191 }
2192 }
2193
2194 /// Represents the same logical types that List can, but contains offsets and
2195 /// sizes allowing for writes in any order and sharing of child values among
2196 /// list values.
2197 ///
2198 /// Generated from these locations:
2199 /// * Table `ListView` in the file `Schema.fbs:105`
2200 #[derive(
2201 Clone,
2202 Debug,
2203 PartialEq,
2204 PartialOrd,
2205 Eq,
2206 Ord,
2207 Hash,
2208 ::serde::Serialize,
2209 ::serde::Deserialize,
2210 )]
2211 pub struct ListView {}
2212
2213 #[allow(clippy::derivable_impls)]
2214 impl ::core::default::Default for ListView {
2215 fn default() -> Self {
2216 Self {}
2217 }
2218 }
2219
2220 impl ListView {
2221 /// Creates a [ListViewBuilder] for serializing an instance of this table.
2222 #[inline]
2223 pub fn builder() -> ListViewBuilder<()> {
2224 ListViewBuilder(())
2225 }
2226
2227 #[allow(clippy::too_many_arguments)]
2228 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
2229 let table_writer: ::planus::table_writer::TableWriter<4> =
2230 ::core::default::Default::default();
2231 unsafe {
2232 table_writer.finish(builder, |_table_writer| {});
2233 }
2234 builder.current_offset()
2235 }
2236 }
2237
2238 impl ::planus::WriteAs<::planus::Offset<ListView>> for ListView {
2239 type Prepared = ::planus::Offset<Self>;
2240
2241 #[inline]
2242 fn prepare(
2243 &self,
2244 builder: &mut ::planus::Builder,
2245 ) -> ::planus::Offset<ListView> {
2246 ::planus::WriteAsOffset::prepare(self, builder)
2247 }
2248 }
2249
2250 impl ::planus::WriteAsOptional<::planus::Offset<ListView>> for ListView {
2251 type Prepared = ::planus::Offset<Self>;
2252
2253 #[inline]
2254 fn prepare(
2255 &self,
2256 builder: &mut ::planus::Builder,
2257 ) -> ::core::option::Option<::planus::Offset<ListView>>
2258 {
2259 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2260 self, builder,
2261 ))
2262 }
2263 }
2264
2265 impl ::planus::WriteAsOffset<ListView> for ListView {
2266 #[inline]
2267 fn prepare(
2268 &self,
2269 builder: &mut ::planus::Builder,
2270 ) -> ::planus::Offset<ListView> {
2271 ListView::create(builder)
2272 }
2273 }
2274
2275 /// Builder for serializing an instance of the [ListView] type.
2276 ///
2277 /// Can be created using the [ListView::builder] method.
2278 #[derive(Debug)]
2279 #[must_use]
2280 pub struct ListViewBuilder<State>(State);
2281
2282 impl ListViewBuilder<()> {
2283 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ListView].
2284 #[inline]
2285 pub fn finish(
2286 self,
2287 builder: &mut ::planus::Builder,
2288 ) -> ::planus::Offset<ListView>
2289 where
2290 Self: ::planus::WriteAsOffset<ListView>,
2291 {
2292 ::planus::WriteAsOffset::prepare(&self, builder)
2293 }
2294 }
2295
2296 impl ::planus::WriteAs<::planus::Offset<ListView>> for ListViewBuilder<()> {
2297 type Prepared = ::planus::Offset<ListView>;
2298
2299 #[inline]
2300 fn prepare(
2301 &self,
2302 builder: &mut ::planus::Builder,
2303 ) -> ::planus::Offset<ListView> {
2304 ::planus::WriteAsOffset::prepare(self, builder)
2305 }
2306 }
2307
2308 impl ::planus::WriteAsOptional<::planus::Offset<ListView>> for ListViewBuilder<()> {
2309 type Prepared = ::planus::Offset<ListView>;
2310
2311 #[inline]
2312 fn prepare(
2313 &self,
2314 builder: &mut ::planus::Builder,
2315 ) -> ::core::option::Option<::planus::Offset<ListView>>
2316 {
2317 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2318 self, builder,
2319 ))
2320 }
2321 }
2322
2323 impl ::planus::WriteAsOffset<ListView> for ListViewBuilder<()> {
2324 #[inline]
2325 fn prepare(
2326 &self,
2327 builder: &mut ::planus::Builder,
2328 ) -> ::planus::Offset<ListView> {
2329 ListView::create(builder)
2330 }
2331 }
2332
2333 /// Reference to a deserialized [ListView].
2334 #[derive(Copy, Clone)]
2335 pub struct ListViewRef<'a>(::planus::table_reader::Table<'a>);
2336
2337 impl<'a> ListViewRef<'a> {}
2338
2339 impl<'a> ::core::fmt::Debug for ListViewRef<'a> {
2340 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2341 let mut f = f.debug_struct("ListViewRef");
2342
2343 f.finish()
2344 }
2345 }
2346
2347 impl<'a> ::core::convert::TryFrom<ListViewRef<'a>> for ListView {
2348 type Error = ::planus::Error;
2349
2350 fn try_from(_value: ListViewRef<'a>) -> ::planus::Result<Self> {
2351 ::core::result::Result::Ok(Self {})
2352 }
2353 }
2354
2355 impl<'a> ::planus::TableRead<'a> for ListViewRef<'a> {
2356 #[inline]
2357 fn from_buffer(
2358 buffer: ::planus::SliceWithStartOffset<'a>,
2359 offset: usize,
2360 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
2361 {
2362 ::core::result::Result::Ok(Self(
2363 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
2364 ))
2365 }
2366 }
2367
2368 impl<'a> ::planus::VectorReadInner<'a> for ListViewRef<'a> {
2369 type Error = ::planus::Error;
2370 const STRIDE: usize = 4;
2371
2372 unsafe fn from_buffer(
2373 buffer: ::planus::SliceWithStartOffset<'a>,
2374 offset: usize,
2375 ) -> ::planus::Result<Self> {
2376 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
2377 error_kind.with_error_location(
2378 "[ListViewRef]",
2379 "get",
2380 buffer.offset_from_start,
2381 )
2382 })
2383 }
2384 }
2385
2386 /// # Safety
2387 /// The planus compiler generates implementations that initialize
2388 /// the bytes in `write_values`.
2389 unsafe impl ::planus::VectorWrite<::planus::Offset<ListView>> for ListView {
2390 type Value = ::planus::Offset<ListView>;
2391 const STRIDE: usize = 4;
2392 #[inline]
2393 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
2394 ::planus::WriteAs::prepare(self, builder)
2395 }
2396
2397 #[inline]
2398 unsafe fn write_values(
2399 values: &[::planus::Offset<ListView>],
2400 bytes: *mut ::core::mem::MaybeUninit<u8>,
2401 buffer_position: u32,
2402 ) {
2403 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
2404 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
2405 ::planus::WriteAsPrimitive::write(
2406 v,
2407 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
2408 buffer_position - (Self::STRIDE * i) as u32,
2409 );
2410 }
2411 }
2412 }
2413
2414 impl<'a> ::planus::ReadAsRoot<'a> for ListViewRef<'a> {
2415 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
2416 ::planus::TableRead::from_buffer(
2417 ::planus::SliceWithStartOffset {
2418 buffer: slice,
2419 offset_from_start: 0,
2420 },
2421 0,
2422 )
2423 .map_err(|error_kind| {
2424 error_kind.with_error_location("[ListViewRef]", "read_as_root", 0)
2425 })
2426 }
2427 }
2428
2429 /// Same as ListView, but with 64-bit offsets and sizes, allowing to represent
2430 /// extremely large data values.
2431 ///
2432 /// Generated from these locations:
2433 /// * Table `LargeListView` in the file `Schema.fbs:110`
2434 #[derive(
2435 Clone,
2436 Debug,
2437 PartialEq,
2438 PartialOrd,
2439 Eq,
2440 Ord,
2441 Hash,
2442 ::serde::Serialize,
2443 ::serde::Deserialize,
2444 )]
2445 pub struct LargeListView {}
2446
2447 #[allow(clippy::derivable_impls)]
2448 impl ::core::default::Default for LargeListView {
2449 fn default() -> Self {
2450 Self {}
2451 }
2452 }
2453
2454 impl LargeListView {
2455 /// Creates a [LargeListViewBuilder] for serializing an instance of this table.
2456 #[inline]
2457 pub fn builder() -> LargeListViewBuilder<()> {
2458 LargeListViewBuilder(())
2459 }
2460
2461 #[allow(clippy::too_many_arguments)]
2462 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
2463 let table_writer: ::planus::table_writer::TableWriter<4> =
2464 ::core::default::Default::default();
2465 unsafe {
2466 table_writer.finish(builder, |_table_writer| {});
2467 }
2468 builder.current_offset()
2469 }
2470 }
2471
2472 impl ::planus::WriteAs<::planus::Offset<LargeListView>> for LargeListView {
2473 type Prepared = ::planus::Offset<Self>;
2474
2475 #[inline]
2476 fn prepare(
2477 &self,
2478 builder: &mut ::planus::Builder,
2479 ) -> ::planus::Offset<LargeListView> {
2480 ::planus::WriteAsOffset::prepare(self, builder)
2481 }
2482 }
2483
2484 impl ::planus::WriteAsOptional<::planus::Offset<LargeListView>> for LargeListView {
2485 type Prepared = ::planus::Offset<Self>;
2486
2487 #[inline]
2488 fn prepare(
2489 &self,
2490 builder: &mut ::planus::Builder,
2491 ) -> ::core::option::Option<::planus::Offset<LargeListView>>
2492 {
2493 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2494 self, builder,
2495 ))
2496 }
2497 }
2498
2499 impl ::planus::WriteAsOffset<LargeListView> for LargeListView {
2500 #[inline]
2501 fn prepare(
2502 &self,
2503 builder: &mut ::planus::Builder,
2504 ) -> ::planus::Offset<LargeListView> {
2505 LargeListView::create(builder)
2506 }
2507 }
2508
2509 /// Builder for serializing an instance of the [LargeListView] type.
2510 ///
2511 /// Can be created using the [LargeListView::builder] method.
2512 #[derive(Debug)]
2513 #[must_use]
2514 pub struct LargeListViewBuilder<State>(State);
2515
2516 impl LargeListViewBuilder<()> {
2517 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [LargeListView].
2518 #[inline]
2519 pub fn finish(
2520 self,
2521 builder: &mut ::planus::Builder,
2522 ) -> ::planus::Offset<LargeListView>
2523 where
2524 Self: ::planus::WriteAsOffset<LargeListView>,
2525 {
2526 ::planus::WriteAsOffset::prepare(&self, builder)
2527 }
2528 }
2529
2530 impl ::planus::WriteAs<::planus::Offset<LargeListView>> for LargeListViewBuilder<()> {
2531 type Prepared = ::planus::Offset<LargeListView>;
2532
2533 #[inline]
2534 fn prepare(
2535 &self,
2536 builder: &mut ::planus::Builder,
2537 ) -> ::planus::Offset<LargeListView> {
2538 ::planus::WriteAsOffset::prepare(self, builder)
2539 }
2540 }
2541
2542 impl ::planus::WriteAsOptional<::planus::Offset<LargeListView>> for LargeListViewBuilder<()> {
2543 type Prepared = ::planus::Offset<LargeListView>;
2544
2545 #[inline]
2546 fn prepare(
2547 &self,
2548 builder: &mut ::planus::Builder,
2549 ) -> ::core::option::Option<::planus::Offset<LargeListView>>
2550 {
2551 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2552 self, builder,
2553 ))
2554 }
2555 }
2556
2557 impl ::planus::WriteAsOffset<LargeListView> for LargeListViewBuilder<()> {
2558 #[inline]
2559 fn prepare(
2560 &self,
2561 builder: &mut ::planus::Builder,
2562 ) -> ::planus::Offset<LargeListView> {
2563 LargeListView::create(builder)
2564 }
2565 }
2566
2567 /// Reference to a deserialized [LargeListView].
2568 #[derive(Copy, Clone)]
2569 pub struct LargeListViewRef<'a>(::planus::table_reader::Table<'a>);
2570
2571 impl<'a> LargeListViewRef<'a> {}
2572
2573 impl<'a> ::core::fmt::Debug for LargeListViewRef<'a> {
2574 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2575 let mut f = f.debug_struct("LargeListViewRef");
2576
2577 f.finish()
2578 }
2579 }
2580
2581 impl<'a> ::core::convert::TryFrom<LargeListViewRef<'a>> for LargeListView {
2582 type Error = ::planus::Error;
2583
2584 fn try_from(_value: LargeListViewRef<'a>) -> ::planus::Result<Self> {
2585 ::core::result::Result::Ok(Self {})
2586 }
2587 }
2588
2589 impl<'a> ::planus::TableRead<'a> for LargeListViewRef<'a> {
2590 #[inline]
2591 fn from_buffer(
2592 buffer: ::planus::SliceWithStartOffset<'a>,
2593 offset: usize,
2594 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
2595 {
2596 ::core::result::Result::Ok(Self(
2597 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
2598 ))
2599 }
2600 }
2601
2602 impl<'a> ::planus::VectorReadInner<'a> for LargeListViewRef<'a> {
2603 type Error = ::planus::Error;
2604 const STRIDE: usize = 4;
2605
2606 unsafe fn from_buffer(
2607 buffer: ::planus::SliceWithStartOffset<'a>,
2608 offset: usize,
2609 ) -> ::planus::Result<Self> {
2610 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
2611 error_kind.with_error_location(
2612 "[LargeListViewRef]",
2613 "get",
2614 buffer.offset_from_start,
2615 )
2616 })
2617 }
2618 }
2619
2620 /// # Safety
2621 /// The planus compiler generates implementations that initialize
2622 /// the bytes in `write_values`.
2623 unsafe impl ::planus::VectorWrite<::planus::Offset<LargeListView>> for LargeListView {
2624 type Value = ::planus::Offset<LargeListView>;
2625 const STRIDE: usize = 4;
2626 #[inline]
2627 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
2628 ::planus::WriteAs::prepare(self, builder)
2629 }
2630
2631 #[inline]
2632 unsafe fn write_values(
2633 values: &[::planus::Offset<LargeListView>],
2634 bytes: *mut ::core::mem::MaybeUninit<u8>,
2635 buffer_position: u32,
2636 ) {
2637 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
2638 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
2639 ::planus::WriteAsPrimitive::write(
2640 v,
2641 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
2642 buffer_position - (Self::STRIDE * i) as u32,
2643 );
2644 }
2645 }
2646 }
2647
2648 impl<'a> ::planus::ReadAsRoot<'a> for LargeListViewRef<'a> {
2649 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
2650 ::planus::TableRead::from_buffer(
2651 ::planus::SliceWithStartOffset {
2652 buffer: slice,
2653 offset_from_start: 0,
2654 },
2655 0,
2656 )
2657 .map_err(|error_kind| {
2658 error_kind.with_error_location(
2659 "[LargeListViewRef]",
2660 "read_as_root",
2661 0,
2662 )
2663 })
2664 }
2665 }
2666
2667 /// The table `FixedSizeList` in the namespace `org.apache.arrow.flatbuf`
2668 ///
2669 /// Generated from these locations:
2670 /// * Table `FixedSizeList` in the file `Schema.fbs:113`
2671 #[derive(
2672 Clone,
2673 Debug,
2674 PartialEq,
2675 PartialOrd,
2676 Eq,
2677 Ord,
2678 Hash,
2679 ::serde::Serialize,
2680 ::serde::Deserialize,
2681 )]
2682 pub struct FixedSizeList {
2683 /// Number of list items per value
2684 pub list_size: i32,
2685 }
2686
2687 #[allow(clippy::derivable_impls)]
2688 impl ::core::default::Default for FixedSizeList {
2689 fn default() -> Self {
2690 Self { list_size: 0 }
2691 }
2692 }
2693
2694 impl FixedSizeList {
2695 /// Creates a [FixedSizeListBuilder] for serializing an instance of this table.
2696 #[inline]
2697 pub fn builder() -> FixedSizeListBuilder<()> {
2698 FixedSizeListBuilder(())
2699 }
2700
2701 #[allow(clippy::too_many_arguments)]
2702 pub fn create(
2703 builder: &mut ::planus::Builder,
2704 field_list_size: impl ::planus::WriteAsDefault<i32, i32>,
2705 ) -> ::planus::Offset<Self> {
2706 let prepared_list_size = field_list_size.prepare(builder, &0);
2707
2708 let mut table_writer: ::planus::table_writer::TableWriter<6> =
2709 ::core::default::Default::default();
2710 if prepared_list_size.is_some() {
2711 table_writer.write_entry::<i32>(0);
2712 }
2713
2714 unsafe {
2715 table_writer.finish(builder, |object_writer| {
2716 if let ::core::option::Option::Some(prepared_list_size) =
2717 prepared_list_size
2718 {
2719 object_writer.write::<_, _, 4>(&prepared_list_size);
2720 }
2721 });
2722 }
2723 builder.current_offset()
2724 }
2725 }
2726
2727 impl ::planus::WriteAs<::planus::Offset<FixedSizeList>> for FixedSizeList {
2728 type Prepared = ::planus::Offset<Self>;
2729
2730 #[inline]
2731 fn prepare(
2732 &self,
2733 builder: &mut ::planus::Builder,
2734 ) -> ::planus::Offset<FixedSizeList> {
2735 ::planus::WriteAsOffset::prepare(self, builder)
2736 }
2737 }
2738
2739 impl ::planus::WriteAsOptional<::planus::Offset<FixedSizeList>> for FixedSizeList {
2740 type Prepared = ::planus::Offset<Self>;
2741
2742 #[inline]
2743 fn prepare(
2744 &self,
2745 builder: &mut ::planus::Builder,
2746 ) -> ::core::option::Option<::planus::Offset<FixedSizeList>>
2747 {
2748 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2749 self, builder,
2750 ))
2751 }
2752 }
2753
2754 impl ::planus::WriteAsOffset<FixedSizeList> for FixedSizeList {
2755 #[inline]
2756 fn prepare(
2757 &self,
2758 builder: &mut ::planus::Builder,
2759 ) -> ::planus::Offset<FixedSizeList> {
2760 FixedSizeList::create(builder, self.list_size)
2761 }
2762 }
2763
2764 /// Builder for serializing an instance of the [FixedSizeList] type.
2765 ///
2766 /// Can be created using the [FixedSizeList::builder] method.
2767 #[derive(Debug)]
2768 #[must_use]
2769 pub struct FixedSizeListBuilder<State>(State);
2770
2771 impl FixedSizeListBuilder<()> {
2772 /// Setter for the [`listSize` field](FixedSizeList#structfield.list_size).
2773 #[inline]
2774 #[allow(clippy::type_complexity)]
2775 pub fn list_size<T0>(self, value: T0) -> FixedSizeListBuilder<(T0,)>
2776 where
2777 T0: ::planus::WriteAsDefault<i32, i32>,
2778 {
2779 FixedSizeListBuilder((value,))
2780 }
2781
2782 /// Sets the [`listSize` field](FixedSizeList#structfield.list_size) to the default value.
2783 #[inline]
2784 #[allow(clippy::type_complexity)]
2785 pub fn list_size_as_default(
2786 self,
2787 ) -> FixedSizeListBuilder<(::planus::DefaultValue,)>
2788 {
2789 self.list_size(::planus::DefaultValue)
2790 }
2791 }
2792
2793 impl<T0> FixedSizeListBuilder<(T0,)> {
2794 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [FixedSizeList].
2795 #[inline]
2796 pub fn finish(
2797 self,
2798 builder: &mut ::planus::Builder,
2799 ) -> ::planus::Offset<FixedSizeList>
2800 where
2801 Self: ::planus::WriteAsOffset<FixedSizeList>,
2802 {
2803 ::planus::WriteAsOffset::prepare(&self, builder)
2804 }
2805 }
2806
2807 impl<T0: ::planus::WriteAsDefault<i32, i32>>
2808 ::planus::WriteAs<::planus::Offset<FixedSizeList>>
2809 for FixedSizeListBuilder<(T0,)>
2810 {
2811 type Prepared = ::planus::Offset<FixedSizeList>;
2812
2813 #[inline]
2814 fn prepare(
2815 &self,
2816 builder: &mut ::planus::Builder,
2817 ) -> ::planus::Offset<FixedSizeList> {
2818 ::planus::WriteAsOffset::prepare(self, builder)
2819 }
2820 }
2821
2822 impl<T0: ::planus::WriteAsDefault<i32, i32>>
2823 ::planus::WriteAsOptional<::planus::Offset<FixedSizeList>>
2824 for FixedSizeListBuilder<(T0,)>
2825 {
2826 type Prepared = ::planus::Offset<FixedSizeList>;
2827
2828 #[inline]
2829 fn prepare(
2830 &self,
2831 builder: &mut ::planus::Builder,
2832 ) -> ::core::option::Option<::planus::Offset<FixedSizeList>>
2833 {
2834 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
2835 self, builder,
2836 ))
2837 }
2838 }
2839
2840 impl<T0: ::planus::WriteAsDefault<i32, i32>>
2841 ::planus::WriteAsOffset<FixedSizeList> for FixedSizeListBuilder<(T0,)>
2842 {
2843 #[inline]
2844 fn prepare(
2845 &self,
2846 builder: &mut ::planus::Builder,
2847 ) -> ::planus::Offset<FixedSizeList> {
2848 let (v0,) = &self.0;
2849 FixedSizeList::create(builder, v0)
2850 }
2851 }
2852
2853 /// Reference to a deserialized [FixedSizeList].
2854 #[derive(Copy, Clone)]
2855 pub struct FixedSizeListRef<'a>(::planus::table_reader::Table<'a>);
2856
2857 impl<'a> FixedSizeListRef<'a> {
2858 /// Getter for the [`listSize` field](FixedSizeList#structfield.list_size).
2859 #[inline]
2860 pub fn list_size(&self) -> ::planus::Result<i32> {
2861 ::core::result::Result::Ok(
2862 self.0.access(0, "FixedSizeList", "list_size")?.unwrap_or(0),
2863 )
2864 }
2865 }
2866
2867 impl<'a> ::core::fmt::Debug for FixedSizeListRef<'a> {
2868 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2869 let mut f = f.debug_struct("FixedSizeListRef");
2870 f.field("list_size", &self.list_size());
2871 f.finish()
2872 }
2873 }
2874
2875 impl<'a> ::core::convert::TryFrom<FixedSizeListRef<'a>> for FixedSizeList {
2876 type Error = ::planus::Error;
2877
2878 #[allow(unreachable_code)]
2879 fn try_from(value: FixedSizeListRef<'a>) -> ::planus::Result<Self> {
2880 ::core::result::Result::Ok(Self {
2881 list_size: ::core::convert::TryInto::try_into(value.list_size()?)?,
2882 })
2883 }
2884 }
2885
2886 impl<'a> ::planus::TableRead<'a> for FixedSizeListRef<'a> {
2887 #[inline]
2888 fn from_buffer(
2889 buffer: ::planus::SliceWithStartOffset<'a>,
2890 offset: usize,
2891 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
2892 {
2893 ::core::result::Result::Ok(Self(
2894 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
2895 ))
2896 }
2897 }
2898
2899 impl<'a> ::planus::VectorReadInner<'a> for FixedSizeListRef<'a> {
2900 type Error = ::planus::Error;
2901 const STRIDE: usize = 4;
2902
2903 unsafe fn from_buffer(
2904 buffer: ::planus::SliceWithStartOffset<'a>,
2905 offset: usize,
2906 ) -> ::planus::Result<Self> {
2907 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
2908 error_kind.with_error_location(
2909 "[FixedSizeListRef]",
2910 "get",
2911 buffer.offset_from_start,
2912 )
2913 })
2914 }
2915 }
2916
2917 /// # Safety
2918 /// The planus compiler generates implementations that initialize
2919 /// the bytes in `write_values`.
2920 unsafe impl ::planus::VectorWrite<::planus::Offset<FixedSizeList>> for FixedSizeList {
2921 type Value = ::planus::Offset<FixedSizeList>;
2922 const STRIDE: usize = 4;
2923 #[inline]
2924 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
2925 ::planus::WriteAs::prepare(self, builder)
2926 }
2927
2928 #[inline]
2929 unsafe fn write_values(
2930 values: &[::planus::Offset<FixedSizeList>],
2931 bytes: *mut ::core::mem::MaybeUninit<u8>,
2932 buffer_position: u32,
2933 ) {
2934 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
2935 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
2936 ::planus::WriteAsPrimitive::write(
2937 v,
2938 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
2939 buffer_position - (Self::STRIDE * i) as u32,
2940 );
2941 }
2942 }
2943 }
2944
2945 impl<'a> ::planus::ReadAsRoot<'a> for FixedSizeListRef<'a> {
2946 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
2947 ::planus::TableRead::from_buffer(
2948 ::planus::SliceWithStartOffset {
2949 buffer: slice,
2950 offset_from_start: 0,
2951 },
2952 0,
2953 )
2954 .map_err(|error_kind| {
2955 error_kind.with_error_location(
2956 "[FixedSizeListRef]",
2957 "read_as_root",
2958 0,
2959 )
2960 })
2961 }
2962 }
2963
2964 /// A Map is a logical nested type that is represented as
2965 ///
2966 /// List<entries: Struct<key: K, value: V>>
2967 ///
2968 /// In this layout, the keys and values are each respectively contiguous. We do
2969 /// not constrain the key and value types, so the application is responsible
2970 /// for ensuring that the keys are hashable and unique. Whether the keys are sorted
2971 /// may be set in the metadata for this field.
2972 ///
2973 /// In a field with Map type, the field has a child Struct field, which then
2974 /// has two children: key type and the second the value type. The names of the
2975 /// child fields may be respectively "entries", "key", and "value", but this is
2976 /// not enforced.
2977 ///
2978 /// Map
2979 /// ```text
2980 /// - child[0] entries: Struct
2981 /// - child[0] key: K
2982 /// - child[1] value: V
2983 /// ```
2984 /// Neither the "entries" field nor the "key" field may be nullable.
2985 ///
2986 /// The metadata is structured so that Arrow systems without special handling
2987 /// for Map can make Map an alias for List. The "layout" attribute for the Map
2988 /// field must have the same contents as a List.
2989 ///
2990 /// Generated from these locations:
2991 /// * Table `Map` in the file `Schema.fbs:143`
2992 #[derive(
2993 Clone,
2994 Debug,
2995 PartialEq,
2996 PartialOrd,
2997 Eq,
2998 Ord,
2999 Hash,
3000 ::serde::Serialize,
3001 ::serde::Deserialize,
3002 )]
3003 pub struct Map {
3004 /// Set to true if the keys within each value are sorted
3005 pub keys_sorted: bool,
3006 }
3007
3008 #[allow(clippy::derivable_impls)]
3009 impl ::core::default::Default for Map {
3010 fn default() -> Self {
3011 Self { keys_sorted: false }
3012 }
3013 }
3014
3015 impl Map {
3016 /// Creates a [MapBuilder] for serializing an instance of this table.
3017 #[inline]
3018 pub fn builder() -> MapBuilder<()> {
3019 MapBuilder(())
3020 }
3021
3022 #[allow(clippy::too_many_arguments)]
3023 pub fn create(
3024 builder: &mut ::planus::Builder,
3025 field_keys_sorted: impl ::planus::WriteAsDefault<bool, bool>,
3026 ) -> ::planus::Offset<Self> {
3027 let prepared_keys_sorted = field_keys_sorted.prepare(builder, &false);
3028
3029 let mut table_writer: ::planus::table_writer::TableWriter<6> =
3030 ::core::default::Default::default();
3031 if prepared_keys_sorted.is_some() {
3032 table_writer.write_entry::<bool>(0);
3033 }
3034
3035 unsafe {
3036 table_writer.finish(builder, |object_writer| {
3037 if let ::core::option::Option::Some(prepared_keys_sorted) =
3038 prepared_keys_sorted
3039 {
3040 object_writer.write::<_, _, 1>(&prepared_keys_sorted);
3041 }
3042 });
3043 }
3044 builder.current_offset()
3045 }
3046 }
3047
3048 impl ::planus::WriteAs<::planus::Offset<Map>> for Map {
3049 type Prepared = ::planus::Offset<Self>;
3050
3051 #[inline]
3052 fn prepare(
3053 &self,
3054 builder: &mut ::planus::Builder,
3055 ) -> ::planus::Offset<Map> {
3056 ::planus::WriteAsOffset::prepare(self, builder)
3057 }
3058 }
3059
3060 impl ::planus::WriteAsOptional<::planus::Offset<Map>> for Map {
3061 type Prepared = ::planus::Offset<Self>;
3062
3063 #[inline]
3064 fn prepare(
3065 &self,
3066 builder: &mut ::planus::Builder,
3067 ) -> ::core::option::Option<::planus::Offset<Map>> {
3068 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
3069 self, builder,
3070 ))
3071 }
3072 }
3073
3074 impl ::planus::WriteAsOffset<Map> for Map {
3075 #[inline]
3076 fn prepare(
3077 &self,
3078 builder: &mut ::planus::Builder,
3079 ) -> ::planus::Offset<Map> {
3080 Map::create(builder, self.keys_sorted)
3081 }
3082 }
3083
3084 /// Builder for serializing an instance of the [Map] type.
3085 ///
3086 /// Can be created using the [Map::builder] method.
3087 #[derive(Debug)]
3088 #[must_use]
3089 pub struct MapBuilder<State>(State);
3090
3091 impl MapBuilder<()> {
3092 /// Setter for the [`keysSorted` field](Map#structfield.keys_sorted).
3093 #[inline]
3094 #[allow(clippy::type_complexity)]
3095 pub fn keys_sorted<T0>(self, value: T0) -> MapBuilder<(T0,)>
3096 where
3097 T0: ::planus::WriteAsDefault<bool, bool>,
3098 {
3099 MapBuilder((value,))
3100 }
3101
3102 /// Sets the [`keysSorted` field](Map#structfield.keys_sorted) to the default value.
3103 #[inline]
3104 #[allow(clippy::type_complexity)]
3105 pub fn keys_sorted_as_default(
3106 self,
3107 ) -> MapBuilder<(::planus::DefaultValue,)> {
3108 self.keys_sorted(::planus::DefaultValue)
3109 }
3110 }
3111
3112 impl<T0> MapBuilder<(T0,)> {
3113 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Map].
3114 #[inline]
3115 pub fn finish(
3116 self,
3117 builder: &mut ::planus::Builder,
3118 ) -> ::planus::Offset<Map>
3119 where
3120 Self: ::planus::WriteAsOffset<Map>,
3121 {
3122 ::planus::WriteAsOffset::prepare(&self, builder)
3123 }
3124 }
3125
3126 impl<T0: ::planus::WriteAsDefault<bool, bool>>
3127 ::planus::WriteAs<::planus::Offset<Map>> for MapBuilder<(T0,)>
3128 {
3129 type Prepared = ::planus::Offset<Map>;
3130
3131 #[inline]
3132 fn prepare(
3133 &self,
3134 builder: &mut ::planus::Builder,
3135 ) -> ::planus::Offset<Map> {
3136 ::planus::WriteAsOffset::prepare(self, builder)
3137 }
3138 }
3139
3140 impl<T0: ::planus::WriteAsDefault<bool, bool>>
3141 ::planus::WriteAsOptional<::planus::Offset<Map>> for MapBuilder<(T0,)>
3142 {
3143 type Prepared = ::planus::Offset<Map>;
3144
3145 #[inline]
3146 fn prepare(
3147 &self,
3148 builder: &mut ::planus::Builder,
3149 ) -> ::core::option::Option<::planus::Offset<Map>> {
3150 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
3151 self, builder,
3152 ))
3153 }
3154 }
3155
3156 impl<T0: ::planus::WriteAsDefault<bool, bool>> ::planus::WriteAsOffset<Map> for MapBuilder<(T0,)> {
3157 #[inline]
3158 fn prepare(
3159 &self,
3160 builder: &mut ::planus::Builder,
3161 ) -> ::planus::Offset<Map> {
3162 let (v0,) = &self.0;
3163 Map::create(builder, v0)
3164 }
3165 }
3166
3167 /// Reference to a deserialized [Map].
3168 #[derive(Copy, Clone)]
3169 pub struct MapRef<'a>(::planus::table_reader::Table<'a>);
3170
3171 impl<'a> MapRef<'a> {
3172 /// Getter for the [`keysSorted` field](Map#structfield.keys_sorted).
3173 #[inline]
3174 pub fn keys_sorted(&self) -> ::planus::Result<bool> {
3175 ::core::result::Result::Ok(
3176 self.0.access(0, "Map", "keys_sorted")?.unwrap_or(false),
3177 )
3178 }
3179 }
3180
3181 impl<'a> ::core::fmt::Debug for MapRef<'a> {
3182 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
3183 let mut f = f.debug_struct("MapRef");
3184 f.field("keys_sorted", &self.keys_sorted());
3185 f.finish()
3186 }
3187 }
3188
3189 impl<'a> ::core::convert::TryFrom<MapRef<'a>> for Map {
3190 type Error = ::planus::Error;
3191
3192 #[allow(unreachable_code)]
3193 fn try_from(value: MapRef<'a>) -> ::planus::Result<Self> {
3194 ::core::result::Result::Ok(Self {
3195 keys_sorted: ::core::convert::TryInto::try_into(
3196 value.keys_sorted()?,
3197 )?,
3198 })
3199 }
3200 }
3201
3202 impl<'a> ::planus::TableRead<'a> for MapRef<'a> {
3203 #[inline]
3204 fn from_buffer(
3205 buffer: ::planus::SliceWithStartOffset<'a>,
3206 offset: usize,
3207 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
3208 {
3209 ::core::result::Result::Ok(Self(
3210 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
3211 ))
3212 }
3213 }
3214
3215 impl<'a> ::planus::VectorReadInner<'a> for MapRef<'a> {
3216 type Error = ::planus::Error;
3217 const STRIDE: usize = 4;
3218
3219 unsafe fn from_buffer(
3220 buffer: ::planus::SliceWithStartOffset<'a>,
3221 offset: usize,
3222 ) -> ::planus::Result<Self> {
3223 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
3224 error_kind.with_error_location(
3225 "[MapRef]",
3226 "get",
3227 buffer.offset_from_start,
3228 )
3229 })
3230 }
3231 }
3232
3233 /// # Safety
3234 /// The planus compiler generates implementations that initialize
3235 /// the bytes in `write_values`.
3236 unsafe impl ::planus::VectorWrite<::planus::Offset<Map>> for Map {
3237 type Value = ::planus::Offset<Map>;
3238 const STRIDE: usize = 4;
3239 #[inline]
3240 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
3241 ::planus::WriteAs::prepare(self, builder)
3242 }
3243
3244 #[inline]
3245 unsafe fn write_values(
3246 values: &[::planus::Offset<Map>],
3247 bytes: *mut ::core::mem::MaybeUninit<u8>,
3248 buffer_position: u32,
3249 ) {
3250 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
3251 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
3252 ::planus::WriteAsPrimitive::write(
3253 v,
3254 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
3255 buffer_position - (Self::STRIDE * i) as u32,
3256 );
3257 }
3258 }
3259 }
3260
3261 impl<'a> ::planus::ReadAsRoot<'a> for MapRef<'a> {
3262 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
3263 ::planus::TableRead::from_buffer(
3264 ::planus::SliceWithStartOffset {
3265 buffer: slice,
3266 offset_from_start: 0,
3267 },
3268 0,
3269 )
3270 .map_err(|error_kind| {
3271 error_kind.with_error_location("[MapRef]", "read_as_root", 0)
3272 })
3273 }
3274 }
3275
3276 /// The enum `UnionMode` in the namespace `org.apache.arrow.flatbuf`
3277 ///
3278 /// Generated from these locations:
3279 /// * Enum `UnionMode` in the file `Schema.fbs:148`
3280 #[derive(
3281 Copy,
3282 Clone,
3283 Debug,
3284 PartialEq,
3285 Eq,
3286 PartialOrd,
3287 Ord,
3288 Hash,
3289 ::serde::Serialize,
3290 ::serde::Deserialize,
3291 )]
3292 #[repr(i16)]
3293 pub enum UnionMode {
3294 /// The variant `Sparse` in the enum `UnionMode`
3295 Sparse = 0,
3296
3297 /// The variant `Dense` in the enum `UnionMode`
3298 Dense = 1,
3299 }
3300
3301 impl UnionMode {
3302 /// Array containing all valid variants of UnionMode
3303 pub const ENUM_VALUES: [Self; 2] = [Self::Sparse, Self::Dense];
3304 }
3305
3306 impl ::core::convert::TryFrom<i16> for UnionMode {
3307 type Error = ::planus::errors::UnknownEnumTagKind;
3308 #[inline]
3309 fn try_from(
3310 value: i16,
3311 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
3312 {
3313 #[allow(clippy::match_single_binding)]
3314 match value {
3315 0 => ::core::result::Result::Ok(UnionMode::Sparse),
3316 1 => ::core::result::Result::Ok(UnionMode::Dense),
3317
3318 _ => ::core::result::Result::Err(
3319 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
3320 ),
3321 }
3322 }
3323 }
3324
3325 impl ::core::convert::From<UnionMode> for i16 {
3326 #[inline]
3327 fn from(value: UnionMode) -> Self {
3328 value as i16
3329 }
3330 }
3331
3332 /// # Safety
3333 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
3334 unsafe impl ::planus::Primitive for UnionMode {
3335 const ALIGNMENT: usize = 2;
3336 const SIZE: usize = 2;
3337 }
3338
3339 impl ::planus::WriteAsPrimitive<UnionMode> for UnionMode {
3340 #[inline]
3341 fn write<const N: usize>(
3342 &self,
3343 cursor: ::planus::Cursor<'_, N>,
3344 buffer_position: u32,
3345 ) {
3346 (*self as i16).write(cursor, buffer_position);
3347 }
3348 }
3349
3350 impl ::planus::WriteAs<UnionMode> for UnionMode {
3351 type Prepared = Self;
3352
3353 #[inline]
3354 fn prepare(&self, _builder: &mut ::planus::Builder) -> UnionMode {
3355 *self
3356 }
3357 }
3358
3359 impl ::planus::WriteAsDefault<UnionMode, UnionMode> for UnionMode {
3360 type Prepared = Self;
3361
3362 #[inline]
3363 fn prepare(
3364 &self,
3365 _builder: &mut ::planus::Builder,
3366 default: &UnionMode,
3367 ) -> ::core::option::Option<UnionMode> {
3368 if self == default {
3369 ::core::option::Option::None
3370 } else {
3371 ::core::option::Option::Some(*self)
3372 }
3373 }
3374 }
3375
3376 impl ::planus::WriteAsOptional<UnionMode> for UnionMode {
3377 type Prepared = Self;
3378
3379 #[inline]
3380 fn prepare(
3381 &self,
3382 _builder: &mut ::planus::Builder,
3383 ) -> ::core::option::Option<UnionMode> {
3384 ::core::option::Option::Some(*self)
3385 }
3386 }
3387
3388 impl<'buf> ::planus::TableRead<'buf> for UnionMode {
3389 #[inline]
3390 fn from_buffer(
3391 buffer: ::planus::SliceWithStartOffset<'buf>,
3392 offset: usize,
3393 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
3394 {
3395 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
3396 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
3397 }
3398 }
3399
3400 impl<'buf> ::planus::VectorReadInner<'buf> for UnionMode {
3401 type Error = ::planus::errors::UnknownEnumTag;
3402 const STRIDE: usize = 2;
3403 #[inline]
3404 unsafe fn from_buffer(
3405 buffer: ::planus::SliceWithStartOffset<'buf>,
3406 offset: usize,
3407 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
3408 {
3409 let value = unsafe {
3410 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
3411 };
3412 let value: ::core::result::Result<Self, _> =
3413 ::core::convert::TryInto::try_into(value);
3414 value.map_err(|error_kind| {
3415 error_kind.with_error_location(
3416 "UnionMode",
3417 "VectorRead::from_buffer",
3418 buffer.offset_from_start,
3419 )
3420 })
3421 }
3422 }
3423
3424 /// # Safety
3425 /// The planus compiler generates implementations that initialize
3426 /// the bytes in `write_values`.
3427 unsafe impl ::planus::VectorWrite<UnionMode> for UnionMode {
3428 const STRIDE: usize = 2;
3429
3430 type Value = Self;
3431
3432 #[inline]
3433 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
3434 *self
3435 }
3436
3437 #[inline]
3438 unsafe fn write_values(
3439 values: &[Self],
3440 bytes: *mut ::core::mem::MaybeUninit<u8>,
3441 buffer_position: u32,
3442 ) {
3443 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
3444 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
3445 ::planus::WriteAsPrimitive::write(
3446 v,
3447 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
3448 buffer_position - (2 * i) as u32,
3449 );
3450 }
3451 }
3452 }
3453
3454 /// A union is a complex type with children in Field
3455 /// By default ids in the type vector refer to the offsets in the children
3456 /// optionally typeIds provides an indirection between the child offset and the type id
3457 /// for each child `typeIds[offset]` is the id used in the type vector
3458 ///
3459 /// Generated from these locations:
3460 /// * Table `Union` in the file `Schema.fbs:154`
3461 #[derive(
3462 Clone,
3463 Debug,
3464 PartialEq,
3465 PartialOrd,
3466 Eq,
3467 Ord,
3468 Hash,
3469 ::serde::Serialize,
3470 ::serde::Deserialize,
3471 )]
3472 pub struct Union {
3473 /// The field `mode` in the table `Union`
3474 pub mode: self::UnionMode,
3475 /// The field `typeIds` in the table `Union`
3476 pub type_ids: ::core::option::Option<::planus::alloc::vec::Vec<i32>>,
3477 }
3478
3479 #[allow(clippy::derivable_impls)]
3480 impl ::core::default::Default for Union {
3481 fn default() -> Self {
3482 Self {
3483 mode: self::UnionMode::Sparse,
3484 type_ids: ::core::default::Default::default(),
3485 }
3486 }
3487 }
3488
3489 impl Union {
3490 /// Creates a [UnionBuilder] for serializing an instance of this table.
3491 #[inline]
3492 pub fn builder() -> UnionBuilder<()> {
3493 UnionBuilder(())
3494 }
3495
3496 #[allow(clippy::too_many_arguments)]
3497 pub fn create(
3498 builder: &mut ::planus::Builder,
3499 field_mode: impl ::planus::WriteAsDefault<self::UnionMode, self::UnionMode>,
3500 field_type_ids: impl ::planus::WriteAsOptional<::planus::Offset<[i32]>>,
3501 ) -> ::planus::Offset<Self> {
3502 let prepared_mode =
3503 field_mode.prepare(builder, &self::UnionMode::Sparse);
3504 let prepared_type_ids = field_type_ids.prepare(builder);
3505
3506 let mut table_writer: ::planus::table_writer::TableWriter<8> =
3507 ::core::default::Default::default();
3508 if prepared_type_ids.is_some() {
3509 table_writer.write_entry::<::planus::Offset<[i32]>>(1);
3510 }
3511 if prepared_mode.is_some() {
3512 table_writer.write_entry::<self::UnionMode>(0);
3513 }
3514
3515 unsafe {
3516 table_writer.finish(builder, |object_writer| {
3517 if let ::core::option::Option::Some(prepared_type_ids) =
3518 prepared_type_ids
3519 {
3520 object_writer.write::<_, _, 4>(&prepared_type_ids);
3521 }
3522 if let ::core::option::Option::Some(prepared_mode) =
3523 prepared_mode
3524 {
3525 object_writer.write::<_, _, 2>(&prepared_mode);
3526 }
3527 });
3528 }
3529 builder.current_offset()
3530 }
3531 }
3532
3533 impl ::planus::WriteAs<::planus::Offset<Union>> for Union {
3534 type Prepared = ::planus::Offset<Self>;
3535
3536 #[inline]
3537 fn prepare(
3538 &self,
3539 builder: &mut ::planus::Builder,
3540 ) -> ::planus::Offset<Union> {
3541 ::planus::WriteAsOffset::prepare(self, builder)
3542 }
3543 }
3544
3545 impl ::planus::WriteAsOptional<::planus::Offset<Union>> for Union {
3546 type Prepared = ::planus::Offset<Self>;
3547
3548 #[inline]
3549 fn prepare(
3550 &self,
3551 builder: &mut ::planus::Builder,
3552 ) -> ::core::option::Option<::planus::Offset<Union>>
3553 {
3554 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
3555 self, builder,
3556 ))
3557 }
3558 }
3559
3560 impl ::planus::WriteAsOffset<Union> for Union {
3561 #[inline]
3562 fn prepare(
3563 &self,
3564 builder: &mut ::planus::Builder,
3565 ) -> ::planus::Offset<Union> {
3566 Union::create(builder, self.mode, &self.type_ids)
3567 }
3568 }
3569
3570 /// Builder for serializing an instance of the [Union] type.
3571 ///
3572 /// Can be created using the [Union::builder] method.
3573 #[derive(Debug)]
3574 #[must_use]
3575 pub struct UnionBuilder<State>(State);
3576
3577 impl UnionBuilder<()> {
3578 /// Setter for the [`mode` field](Union#structfield.mode).
3579 #[inline]
3580 #[allow(clippy::type_complexity)]
3581 pub fn mode<T0>(self, value: T0) -> UnionBuilder<(T0,)>
3582 where
3583 T0: ::planus::WriteAsDefault<self::UnionMode, self::UnionMode>,
3584 {
3585 UnionBuilder((value,))
3586 }
3587
3588 /// Sets the [`mode` field](Union#structfield.mode) to the default value.
3589 #[inline]
3590 #[allow(clippy::type_complexity)]
3591 pub fn mode_as_default(self) -> UnionBuilder<(::planus::DefaultValue,)> {
3592 self.mode(::planus::DefaultValue)
3593 }
3594 }
3595
3596 impl<T0> UnionBuilder<(T0,)> {
3597 /// Setter for the [`typeIds` field](Union#structfield.type_ids).
3598 #[inline]
3599 #[allow(clippy::type_complexity)]
3600 pub fn type_ids<T1>(self, value: T1) -> UnionBuilder<(T0, T1)>
3601 where
3602 T1: ::planus::WriteAsOptional<::planus::Offset<[i32]>>,
3603 {
3604 let (v0,) = self.0;
3605 UnionBuilder((v0, value))
3606 }
3607
3608 /// Sets the [`typeIds` field](Union#structfield.type_ids) to null.
3609 #[inline]
3610 #[allow(clippy::type_complexity)]
3611 pub fn type_ids_as_null(self) -> UnionBuilder<(T0, ())> {
3612 self.type_ids(())
3613 }
3614 }
3615
3616 impl<T0, T1> UnionBuilder<(T0, T1)> {
3617 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Union].
3618 #[inline]
3619 pub fn finish(
3620 self,
3621 builder: &mut ::planus::Builder,
3622 ) -> ::planus::Offset<Union>
3623 where
3624 Self: ::planus::WriteAsOffset<Union>,
3625 {
3626 ::planus::WriteAsOffset::prepare(&self, builder)
3627 }
3628 }
3629
3630 impl<
3631 T0: ::planus::WriteAsDefault<self::UnionMode, self::UnionMode>,
3632 T1: ::planus::WriteAsOptional<::planus::Offset<[i32]>>,
3633 > ::planus::WriteAs<::planus::Offset<Union>> for UnionBuilder<(T0, T1)>
3634 {
3635 type Prepared = ::planus::Offset<Union>;
3636
3637 #[inline]
3638 fn prepare(
3639 &self,
3640 builder: &mut ::planus::Builder,
3641 ) -> ::planus::Offset<Union> {
3642 ::planus::WriteAsOffset::prepare(self, builder)
3643 }
3644 }
3645
3646 impl<
3647 T0: ::planus::WriteAsDefault<self::UnionMode, self::UnionMode>,
3648 T1: ::planus::WriteAsOptional<::planus::Offset<[i32]>>,
3649 > ::planus::WriteAsOptional<::planus::Offset<Union>>
3650 for UnionBuilder<(T0, T1)>
3651 {
3652 type Prepared = ::planus::Offset<Union>;
3653
3654 #[inline]
3655 fn prepare(
3656 &self,
3657 builder: &mut ::planus::Builder,
3658 ) -> ::core::option::Option<::planus::Offset<Union>>
3659 {
3660 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
3661 self, builder,
3662 ))
3663 }
3664 }
3665
3666 impl<
3667 T0: ::planus::WriteAsDefault<self::UnionMode, self::UnionMode>,
3668 T1: ::planus::WriteAsOptional<::planus::Offset<[i32]>>,
3669 > ::planus::WriteAsOffset<Union> for UnionBuilder<(T0, T1)>
3670 {
3671 #[inline]
3672 fn prepare(
3673 &self,
3674 builder: &mut ::planus::Builder,
3675 ) -> ::planus::Offset<Union> {
3676 let (v0, v1) = &self.0;
3677 Union::create(builder, v0, v1)
3678 }
3679 }
3680
3681 /// Reference to a deserialized [Union].
3682 #[derive(Copy, Clone)]
3683 pub struct UnionRef<'a>(::planus::table_reader::Table<'a>);
3684
3685 impl<'a> UnionRef<'a> {
3686 /// Getter for the [`mode` field](Union#structfield.mode).
3687 #[inline]
3688 pub fn mode(&self) -> ::planus::Result<self::UnionMode> {
3689 ::core::result::Result::Ok(
3690 self.0
3691 .access(0, "Union", "mode")?
3692 .unwrap_or(self::UnionMode::Sparse),
3693 )
3694 }
3695
3696 /// Getter for the [`typeIds` field](Union#structfield.type_ids).
3697 #[inline]
3698 pub fn type_ids(
3699 &self,
3700 ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i32>>>
3701 {
3702 self.0.access(1, "Union", "type_ids")
3703 }
3704 }
3705
3706 impl<'a> ::core::fmt::Debug for UnionRef<'a> {
3707 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
3708 let mut f = f.debug_struct("UnionRef");
3709 f.field("mode", &self.mode());
3710 if let ::core::option::Option::Some(field_type_ids) =
3711 self.type_ids().transpose()
3712 {
3713 f.field("type_ids", &field_type_ids);
3714 }
3715 f.finish()
3716 }
3717 }
3718
3719 impl<'a> ::core::convert::TryFrom<UnionRef<'a>> for Union {
3720 type Error = ::planus::Error;
3721
3722 #[allow(unreachable_code)]
3723 fn try_from(value: UnionRef<'a>) -> ::planus::Result<Self> {
3724 ::core::result::Result::Ok(Self {
3725 mode: ::core::convert::TryInto::try_into(value.mode()?)?,
3726 type_ids: if let ::core::option::Option::Some(type_ids) =
3727 value.type_ids()?
3728 {
3729 ::core::option::Option::Some(type_ids.to_vec()?)
3730 } else {
3731 ::core::option::Option::None
3732 },
3733 })
3734 }
3735 }
3736
3737 impl<'a> ::planus::TableRead<'a> for UnionRef<'a> {
3738 #[inline]
3739 fn from_buffer(
3740 buffer: ::planus::SliceWithStartOffset<'a>,
3741 offset: usize,
3742 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
3743 {
3744 ::core::result::Result::Ok(Self(
3745 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
3746 ))
3747 }
3748 }
3749
3750 impl<'a> ::planus::VectorReadInner<'a> for UnionRef<'a> {
3751 type Error = ::planus::Error;
3752 const STRIDE: usize = 4;
3753
3754 unsafe fn from_buffer(
3755 buffer: ::planus::SliceWithStartOffset<'a>,
3756 offset: usize,
3757 ) -> ::planus::Result<Self> {
3758 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
3759 error_kind.with_error_location(
3760 "[UnionRef]",
3761 "get",
3762 buffer.offset_from_start,
3763 )
3764 })
3765 }
3766 }
3767
3768 /// # Safety
3769 /// The planus compiler generates implementations that initialize
3770 /// the bytes in `write_values`.
3771 unsafe impl ::planus::VectorWrite<::planus::Offset<Union>> for Union {
3772 type Value = ::planus::Offset<Union>;
3773 const STRIDE: usize = 4;
3774 #[inline]
3775 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
3776 ::planus::WriteAs::prepare(self, builder)
3777 }
3778
3779 #[inline]
3780 unsafe fn write_values(
3781 values: &[::planus::Offset<Union>],
3782 bytes: *mut ::core::mem::MaybeUninit<u8>,
3783 buffer_position: u32,
3784 ) {
3785 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
3786 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
3787 ::planus::WriteAsPrimitive::write(
3788 v,
3789 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
3790 buffer_position - (Self::STRIDE * i) as u32,
3791 );
3792 }
3793 }
3794 }
3795
3796 impl<'a> ::planus::ReadAsRoot<'a> for UnionRef<'a> {
3797 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
3798 ::planus::TableRead::from_buffer(
3799 ::planus::SliceWithStartOffset {
3800 buffer: slice,
3801 offset_from_start: 0,
3802 },
3803 0,
3804 )
3805 .map_err(|error_kind| {
3806 error_kind.with_error_location("[UnionRef]", "read_as_root", 0)
3807 })
3808 }
3809 }
3810
3811 /// The table `Int` in the namespace `org.apache.arrow.flatbuf`
3812 ///
3813 /// Generated from these locations:
3814 /// * Table `Int` in the file `Schema.fbs:159`
3815 #[derive(
3816 Clone,
3817 Debug,
3818 PartialEq,
3819 PartialOrd,
3820 Eq,
3821 Ord,
3822 Hash,
3823 ::serde::Serialize,
3824 ::serde::Deserialize,
3825 )]
3826 pub struct Int {
3827 /// The field `bitWidth` in the table `Int`
3828 pub bit_width: i32,
3829 /// The field `is_signed` in the table `Int`
3830 pub is_signed: bool,
3831 }
3832
3833 #[allow(clippy::derivable_impls)]
3834 impl ::core::default::Default for Int {
3835 fn default() -> Self {
3836 Self {
3837 bit_width: 0,
3838 is_signed: false,
3839 }
3840 }
3841 }
3842
3843 impl Int {
3844 /// Creates a [IntBuilder] for serializing an instance of this table.
3845 #[inline]
3846 pub fn builder() -> IntBuilder<()> {
3847 IntBuilder(())
3848 }
3849
3850 #[allow(clippy::too_many_arguments)]
3851 pub fn create(
3852 builder: &mut ::planus::Builder,
3853 field_bit_width: impl ::planus::WriteAsDefault<i32, i32>,
3854 field_is_signed: impl ::planus::WriteAsDefault<bool, bool>,
3855 ) -> ::planus::Offset<Self> {
3856 let prepared_bit_width = field_bit_width.prepare(builder, &0);
3857 let prepared_is_signed = field_is_signed.prepare(builder, &false);
3858
3859 let mut table_writer: ::planus::table_writer::TableWriter<8> =
3860 ::core::default::Default::default();
3861 if prepared_bit_width.is_some() {
3862 table_writer.write_entry::<i32>(0);
3863 }
3864 if prepared_is_signed.is_some() {
3865 table_writer.write_entry::<bool>(1);
3866 }
3867
3868 unsafe {
3869 table_writer.finish(builder, |object_writer| {
3870 if let ::core::option::Option::Some(prepared_bit_width) =
3871 prepared_bit_width
3872 {
3873 object_writer.write::<_, _, 4>(&prepared_bit_width);
3874 }
3875 if let ::core::option::Option::Some(prepared_is_signed) =
3876 prepared_is_signed
3877 {
3878 object_writer.write::<_, _, 1>(&prepared_is_signed);
3879 }
3880 });
3881 }
3882 builder.current_offset()
3883 }
3884 }
3885
3886 impl ::planus::WriteAs<::planus::Offset<Int>> for Int {
3887 type Prepared = ::planus::Offset<Self>;
3888
3889 #[inline]
3890 fn prepare(
3891 &self,
3892 builder: &mut ::planus::Builder,
3893 ) -> ::planus::Offset<Int> {
3894 ::planus::WriteAsOffset::prepare(self, builder)
3895 }
3896 }
3897
3898 impl ::planus::WriteAsOptional<::planus::Offset<Int>> for Int {
3899 type Prepared = ::planus::Offset<Self>;
3900
3901 #[inline]
3902 fn prepare(
3903 &self,
3904 builder: &mut ::planus::Builder,
3905 ) -> ::core::option::Option<::planus::Offset<Int>> {
3906 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
3907 self, builder,
3908 ))
3909 }
3910 }
3911
3912 impl ::planus::WriteAsOffset<Int> for Int {
3913 #[inline]
3914 fn prepare(
3915 &self,
3916 builder: &mut ::planus::Builder,
3917 ) -> ::planus::Offset<Int> {
3918 Int::create(builder, self.bit_width, self.is_signed)
3919 }
3920 }
3921
3922 /// Builder for serializing an instance of the [Int] type.
3923 ///
3924 /// Can be created using the [Int::builder] method.
3925 #[derive(Debug)]
3926 #[must_use]
3927 pub struct IntBuilder<State>(State);
3928
3929 impl IntBuilder<()> {
3930 /// Setter for the [`bitWidth` field](Int#structfield.bit_width).
3931 #[inline]
3932 #[allow(clippy::type_complexity)]
3933 pub fn bit_width<T0>(self, value: T0) -> IntBuilder<(T0,)>
3934 where
3935 T0: ::planus::WriteAsDefault<i32, i32>,
3936 {
3937 IntBuilder((value,))
3938 }
3939
3940 /// Sets the [`bitWidth` field](Int#structfield.bit_width) to the default value.
3941 #[inline]
3942 #[allow(clippy::type_complexity)]
3943 pub fn bit_width_as_default(self) -> IntBuilder<(::planus::DefaultValue,)> {
3944 self.bit_width(::planus::DefaultValue)
3945 }
3946 }
3947
3948 impl<T0> IntBuilder<(T0,)> {
3949 /// Setter for the [`is_signed` field](Int#structfield.is_signed).
3950 #[inline]
3951 #[allow(clippy::type_complexity)]
3952 pub fn is_signed<T1>(self, value: T1) -> IntBuilder<(T0, T1)>
3953 where
3954 T1: ::planus::WriteAsDefault<bool, bool>,
3955 {
3956 let (v0,) = self.0;
3957 IntBuilder((v0, value))
3958 }
3959
3960 /// Sets the [`is_signed` field](Int#structfield.is_signed) to the default value.
3961 #[inline]
3962 #[allow(clippy::type_complexity)]
3963 pub fn is_signed_as_default(
3964 self,
3965 ) -> IntBuilder<(T0, ::planus::DefaultValue)> {
3966 self.is_signed(::planus::DefaultValue)
3967 }
3968 }
3969
3970 impl<T0, T1> IntBuilder<(T0, T1)> {
3971 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Int].
3972 #[inline]
3973 pub fn finish(
3974 self,
3975 builder: &mut ::planus::Builder,
3976 ) -> ::planus::Offset<Int>
3977 where
3978 Self: ::planus::WriteAsOffset<Int>,
3979 {
3980 ::planus::WriteAsOffset::prepare(&self, builder)
3981 }
3982 }
3983
3984 impl<
3985 T0: ::planus::WriteAsDefault<i32, i32>,
3986 T1: ::planus::WriteAsDefault<bool, bool>,
3987 > ::planus::WriteAs<::planus::Offset<Int>> for IntBuilder<(T0, T1)>
3988 {
3989 type Prepared = ::planus::Offset<Int>;
3990
3991 #[inline]
3992 fn prepare(
3993 &self,
3994 builder: &mut ::planus::Builder,
3995 ) -> ::planus::Offset<Int> {
3996 ::planus::WriteAsOffset::prepare(self, builder)
3997 }
3998 }
3999
4000 impl<
4001 T0: ::planus::WriteAsDefault<i32, i32>,
4002 T1: ::planus::WriteAsDefault<bool, bool>,
4003 > ::planus::WriteAsOptional<::planus::Offset<Int>>
4004 for IntBuilder<(T0, T1)>
4005 {
4006 type Prepared = ::planus::Offset<Int>;
4007
4008 #[inline]
4009 fn prepare(
4010 &self,
4011 builder: &mut ::planus::Builder,
4012 ) -> ::core::option::Option<::planus::Offset<Int>> {
4013 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4014 self, builder,
4015 ))
4016 }
4017 }
4018
4019 impl<
4020 T0: ::planus::WriteAsDefault<i32, i32>,
4021 T1: ::planus::WriteAsDefault<bool, bool>,
4022 > ::planus::WriteAsOffset<Int> for IntBuilder<(T0, T1)>
4023 {
4024 #[inline]
4025 fn prepare(
4026 &self,
4027 builder: &mut ::planus::Builder,
4028 ) -> ::planus::Offset<Int> {
4029 let (v0, v1) = &self.0;
4030 Int::create(builder, v0, v1)
4031 }
4032 }
4033
4034 /// Reference to a deserialized [Int].
4035 #[derive(Copy, Clone)]
4036 pub struct IntRef<'a>(::planus::table_reader::Table<'a>);
4037
4038 impl<'a> IntRef<'a> {
4039 /// Getter for the [`bitWidth` field](Int#structfield.bit_width).
4040 #[inline]
4041 pub fn bit_width(&self) -> ::planus::Result<i32> {
4042 ::core::result::Result::Ok(
4043 self.0.access(0, "Int", "bit_width")?.unwrap_or(0),
4044 )
4045 }
4046
4047 /// Getter for the [`is_signed` field](Int#structfield.is_signed).
4048 #[inline]
4049 pub fn is_signed(&self) -> ::planus::Result<bool> {
4050 ::core::result::Result::Ok(
4051 self.0.access(1, "Int", "is_signed")?.unwrap_or(false),
4052 )
4053 }
4054 }
4055
4056 impl<'a> ::core::fmt::Debug for IntRef<'a> {
4057 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
4058 let mut f = f.debug_struct("IntRef");
4059 f.field("bit_width", &self.bit_width());
4060 f.field("is_signed", &self.is_signed());
4061 f.finish()
4062 }
4063 }
4064
4065 impl<'a> ::core::convert::TryFrom<IntRef<'a>> for Int {
4066 type Error = ::planus::Error;
4067
4068 #[allow(unreachable_code)]
4069 fn try_from(value: IntRef<'a>) -> ::planus::Result<Self> {
4070 ::core::result::Result::Ok(Self {
4071 bit_width: ::core::convert::TryInto::try_into(value.bit_width()?)?,
4072 is_signed: ::core::convert::TryInto::try_into(value.is_signed()?)?,
4073 })
4074 }
4075 }
4076
4077 impl<'a> ::planus::TableRead<'a> for IntRef<'a> {
4078 #[inline]
4079 fn from_buffer(
4080 buffer: ::planus::SliceWithStartOffset<'a>,
4081 offset: usize,
4082 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
4083 {
4084 ::core::result::Result::Ok(Self(
4085 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
4086 ))
4087 }
4088 }
4089
4090 impl<'a> ::planus::VectorReadInner<'a> for IntRef<'a> {
4091 type Error = ::planus::Error;
4092 const STRIDE: usize = 4;
4093
4094 unsafe fn from_buffer(
4095 buffer: ::planus::SliceWithStartOffset<'a>,
4096 offset: usize,
4097 ) -> ::planus::Result<Self> {
4098 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
4099 error_kind.with_error_location(
4100 "[IntRef]",
4101 "get",
4102 buffer.offset_from_start,
4103 )
4104 })
4105 }
4106 }
4107
4108 /// # Safety
4109 /// The planus compiler generates implementations that initialize
4110 /// the bytes in `write_values`.
4111 unsafe impl ::planus::VectorWrite<::planus::Offset<Int>> for Int {
4112 type Value = ::planus::Offset<Int>;
4113 const STRIDE: usize = 4;
4114 #[inline]
4115 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
4116 ::planus::WriteAs::prepare(self, builder)
4117 }
4118
4119 #[inline]
4120 unsafe fn write_values(
4121 values: &[::planus::Offset<Int>],
4122 bytes: *mut ::core::mem::MaybeUninit<u8>,
4123 buffer_position: u32,
4124 ) {
4125 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
4126 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
4127 ::planus::WriteAsPrimitive::write(
4128 v,
4129 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
4130 buffer_position - (Self::STRIDE * i) as u32,
4131 );
4132 }
4133 }
4134 }
4135
4136 impl<'a> ::planus::ReadAsRoot<'a> for IntRef<'a> {
4137 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
4138 ::planus::TableRead::from_buffer(
4139 ::planus::SliceWithStartOffset {
4140 buffer: slice,
4141 offset_from_start: 0,
4142 },
4143 0,
4144 )
4145 .map_err(|error_kind| {
4146 error_kind.with_error_location("[IntRef]", "read_as_root", 0)
4147 })
4148 }
4149 }
4150
4151 /// The enum `Precision` in the namespace `org.apache.arrow.flatbuf`
4152 ///
4153 /// Generated from these locations:
4154 /// * Enum `Precision` in the file `Schema.fbs:164`
4155 #[derive(
4156 Copy,
4157 Clone,
4158 Debug,
4159 PartialEq,
4160 Eq,
4161 PartialOrd,
4162 Ord,
4163 Hash,
4164 ::serde::Serialize,
4165 ::serde::Deserialize,
4166 )]
4167 #[repr(i16)]
4168 pub enum Precision {
4169 /// The variant `HALF` in the enum `Precision`
4170 Half = 0,
4171
4172 /// The variant `SINGLE` in the enum `Precision`
4173 Single = 1,
4174
4175 /// The variant `DOUBLE` in the enum `Precision`
4176 Double = 2,
4177 }
4178
4179 impl Precision {
4180 /// Array containing all valid variants of Precision
4181 pub const ENUM_VALUES: [Self; 3] = [Self::Half, Self::Single, Self::Double];
4182 }
4183
4184 impl ::core::convert::TryFrom<i16> for Precision {
4185 type Error = ::planus::errors::UnknownEnumTagKind;
4186 #[inline]
4187 fn try_from(
4188 value: i16,
4189 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
4190 {
4191 #[allow(clippy::match_single_binding)]
4192 match value {
4193 0 => ::core::result::Result::Ok(Precision::Half),
4194 1 => ::core::result::Result::Ok(Precision::Single),
4195 2 => ::core::result::Result::Ok(Precision::Double),
4196
4197 _ => ::core::result::Result::Err(
4198 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
4199 ),
4200 }
4201 }
4202 }
4203
4204 impl ::core::convert::From<Precision> for i16 {
4205 #[inline]
4206 fn from(value: Precision) -> Self {
4207 value as i16
4208 }
4209 }
4210
4211 /// # Safety
4212 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
4213 unsafe impl ::planus::Primitive for Precision {
4214 const ALIGNMENT: usize = 2;
4215 const SIZE: usize = 2;
4216 }
4217
4218 impl ::planus::WriteAsPrimitive<Precision> for Precision {
4219 #[inline]
4220 fn write<const N: usize>(
4221 &self,
4222 cursor: ::planus::Cursor<'_, N>,
4223 buffer_position: u32,
4224 ) {
4225 (*self as i16).write(cursor, buffer_position);
4226 }
4227 }
4228
4229 impl ::planus::WriteAs<Precision> for Precision {
4230 type Prepared = Self;
4231
4232 #[inline]
4233 fn prepare(&self, _builder: &mut ::planus::Builder) -> Precision {
4234 *self
4235 }
4236 }
4237
4238 impl ::planus::WriteAsDefault<Precision, Precision> for Precision {
4239 type Prepared = Self;
4240
4241 #[inline]
4242 fn prepare(
4243 &self,
4244 _builder: &mut ::planus::Builder,
4245 default: &Precision,
4246 ) -> ::core::option::Option<Precision> {
4247 if self == default {
4248 ::core::option::Option::None
4249 } else {
4250 ::core::option::Option::Some(*self)
4251 }
4252 }
4253 }
4254
4255 impl ::planus::WriteAsOptional<Precision> for Precision {
4256 type Prepared = Self;
4257
4258 #[inline]
4259 fn prepare(
4260 &self,
4261 _builder: &mut ::planus::Builder,
4262 ) -> ::core::option::Option<Precision> {
4263 ::core::option::Option::Some(*self)
4264 }
4265 }
4266
4267 impl<'buf> ::planus::TableRead<'buf> for Precision {
4268 #[inline]
4269 fn from_buffer(
4270 buffer: ::planus::SliceWithStartOffset<'buf>,
4271 offset: usize,
4272 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
4273 {
4274 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
4275 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
4276 }
4277 }
4278
4279 impl<'buf> ::planus::VectorReadInner<'buf> for Precision {
4280 type Error = ::planus::errors::UnknownEnumTag;
4281 const STRIDE: usize = 2;
4282 #[inline]
4283 unsafe fn from_buffer(
4284 buffer: ::planus::SliceWithStartOffset<'buf>,
4285 offset: usize,
4286 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
4287 {
4288 let value = unsafe {
4289 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
4290 };
4291 let value: ::core::result::Result<Self, _> =
4292 ::core::convert::TryInto::try_into(value);
4293 value.map_err(|error_kind| {
4294 error_kind.with_error_location(
4295 "Precision",
4296 "VectorRead::from_buffer",
4297 buffer.offset_from_start,
4298 )
4299 })
4300 }
4301 }
4302
4303 /// # Safety
4304 /// The planus compiler generates implementations that initialize
4305 /// the bytes in `write_values`.
4306 unsafe impl ::planus::VectorWrite<Precision> for Precision {
4307 const STRIDE: usize = 2;
4308
4309 type Value = Self;
4310
4311 #[inline]
4312 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
4313 *self
4314 }
4315
4316 #[inline]
4317 unsafe fn write_values(
4318 values: &[Self],
4319 bytes: *mut ::core::mem::MaybeUninit<u8>,
4320 buffer_position: u32,
4321 ) {
4322 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
4323 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
4324 ::planus::WriteAsPrimitive::write(
4325 v,
4326 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
4327 buffer_position - (2 * i) as u32,
4328 );
4329 }
4330 }
4331 }
4332
4333 /// The table `FloatingPoint` in the namespace `org.apache.arrow.flatbuf`
4334 ///
4335 /// Generated from these locations:
4336 /// * Table `FloatingPoint` in the file `Schema.fbs:166`
4337 #[derive(
4338 Clone,
4339 Debug,
4340 PartialEq,
4341 PartialOrd,
4342 Eq,
4343 Ord,
4344 Hash,
4345 ::serde::Serialize,
4346 ::serde::Deserialize,
4347 )]
4348 pub struct FloatingPoint {
4349 /// The field `precision` in the table `FloatingPoint`
4350 pub precision: self::Precision,
4351 }
4352
4353 #[allow(clippy::derivable_impls)]
4354 impl ::core::default::Default for FloatingPoint {
4355 fn default() -> Self {
4356 Self {
4357 precision: self::Precision::Half,
4358 }
4359 }
4360 }
4361
4362 impl FloatingPoint {
4363 /// Creates a [FloatingPointBuilder] for serializing an instance of this table.
4364 #[inline]
4365 pub fn builder() -> FloatingPointBuilder<()> {
4366 FloatingPointBuilder(())
4367 }
4368
4369 #[allow(clippy::too_many_arguments)]
4370 pub fn create(
4371 builder: &mut ::planus::Builder,
4372 field_precision: impl ::planus::WriteAsDefault<
4373 self::Precision,
4374 self::Precision,
4375 >,
4376 ) -> ::planus::Offset<Self> {
4377 let prepared_precision =
4378 field_precision.prepare(builder, &self::Precision::Half);
4379
4380 let mut table_writer: ::planus::table_writer::TableWriter<6> =
4381 ::core::default::Default::default();
4382 if prepared_precision.is_some() {
4383 table_writer.write_entry::<self::Precision>(0);
4384 }
4385
4386 unsafe {
4387 table_writer.finish(builder, |object_writer| {
4388 if let ::core::option::Option::Some(prepared_precision) =
4389 prepared_precision
4390 {
4391 object_writer.write::<_, _, 2>(&prepared_precision);
4392 }
4393 });
4394 }
4395 builder.current_offset()
4396 }
4397 }
4398
4399 impl ::planus::WriteAs<::planus::Offset<FloatingPoint>> for FloatingPoint {
4400 type Prepared = ::planus::Offset<Self>;
4401
4402 #[inline]
4403 fn prepare(
4404 &self,
4405 builder: &mut ::planus::Builder,
4406 ) -> ::planus::Offset<FloatingPoint> {
4407 ::planus::WriteAsOffset::prepare(self, builder)
4408 }
4409 }
4410
4411 impl ::planus::WriteAsOptional<::planus::Offset<FloatingPoint>> for FloatingPoint {
4412 type Prepared = ::planus::Offset<Self>;
4413
4414 #[inline]
4415 fn prepare(
4416 &self,
4417 builder: &mut ::planus::Builder,
4418 ) -> ::core::option::Option<::planus::Offset<FloatingPoint>>
4419 {
4420 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4421 self, builder,
4422 ))
4423 }
4424 }
4425
4426 impl ::planus::WriteAsOffset<FloatingPoint> for FloatingPoint {
4427 #[inline]
4428 fn prepare(
4429 &self,
4430 builder: &mut ::planus::Builder,
4431 ) -> ::planus::Offset<FloatingPoint> {
4432 FloatingPoint::create(builder, self.precision)
4433 }
4434 }
4435
4436 /// Builder for serializing an instance of the [FloatingPoint] type.
4437 ///
4438 /// Can be created using the [FloatingPoint::builder] method.
4439 #[derive(Debug)]
4440 #[must_use]
4441 pub struct FloatingPointBuilder<State>(State);
4442
4443 impl FloatingPointBuilder<()> {
4444 /// Setter for the [`precision` field](FloatingPoint#structfield.precision).
4445 #[inline]
4446 #[allow(clippy::type_complexity)]
4447 pub fn precision<T0>(self, value: T0) -> FloatingPointBuilder<(T0,)>
4448 where
4449 T0: ::planus::WriteAsDefault<self::Precision, self::Precision>,
4450 {
4451 FloatingPointBuilder((value,))
4452 }
4453
4454 /// Sets the [`precision` field](FloatingPoint#structfield.precision) to the default value.
4455 #[inline]
4456 #[allow(clippy::type_complexity)]
4457 pub fn precision_as_default(
4458 self,
4459 ) -> FloatingPointBuilder<(::planus::DefaultValue,)>
4460 {
4461 self.precision(::planus::DefaultValue)
4462 }
4463 }
4464
4465 impl<T0> FloatingPointBuilder<(T0,)> {
4466 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [FloatingPoint].
4467 #[inline]
4468 pub fn finish(
4469 self,
4470 builder: &mut ::planus::Builder,
4471 ) -> ::planus::Offset<FloatingPoint>
4472 where
4473 Self: ::planus::WriteAsOffset<FloatingPoint>,
4474 {
4475 ::planus::WriteAsOffset::prepare(&self, builder)
4476 }
4477 }
4478
4479 impl<T0: ::planus::WriteAsDefault<self::Precision, self::Precision>>
4480 ::planus::WriteAs<::planus::Offset<FloatingPoint>>
4481 for FloatingPointBuilder<(T0,)>
4482 {
4483 type Prepared = ::planus::Offset<FloatingPoint>;
4484
4485 #[inline]
4486 fn prepare(
4487 &self,
4488 builder: &mut ::planus::Builder,
4489 ) -> ::planus::Offset<FloatingPoint> {
4490 ::planus::WriteAsOffset::prepare(self, builder)
4491 }
4492 }
4493
4494 impl<T0: ::planus::WriteAsDefault<self::Precision, self::Precision>>
4495 ::planus::WriteAsOptional<::planus::Offset<FloatingPoint>>
4496 for FloatingPointBuilder<(T0,)>
4497 {
4498 type Prepared = ::planus::Offset<FloatingPoint>;
4499
4500 #[inline]
4501 fn prepare(
4502 &self,
4503 builder: &mut ::planus::Builder,
4504 ) -> ::core::option::Option<::planus::Offset<FloatingPoint>>
4505 {
4506 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4507 self, builder,
4508 ))
4509 }
4510 }
4511
4512 impl<T0: ::planus::WriteAsDefault<self::Precision, self::Precision>>
4513 ::planus::WriteAsOffset<FloatingPoint> for FloatingPointBuilder<(T0,)>
4514 {
4515 #[inline]
4516 fn prepare(
4517 &self,
4518 builder: &mut ::planus::Builder,
4519 ) -> ::planus::Offset<FloatingPoint> {
4520 let (v0,) = &self.0;
4521 FloatingPoint::create(builder, v0)
4522 }
4523 }
4524
4525 /// Reference to a deserialized [FloatingPoint].
4526 #[derive(Copy, Clone)]
4527 pub struct FloatingPointRef<'a>(::planus::table_reader::Table<'a>);
4528
4529 impl<'a> FloatingPointRef<'a> {
4530 /// Getter for the [`precision` field](FloatingPoint#structfield.precision).
4531 #[inline]
4532 pub fn precision(&self) -> ::planus::Result<self::Precision> {
4533 ::core::result::Result::Ok(
4534 self.0
4535 .access(0, "FloatingPoint", "precision")?
4536 .unwrap_or(self::Precision::Half),
4537 )
4538 }
4539 }
4540
4541 impl<'a> ::core::fmt::Debug for FloatingPointRef<'a> {
4542 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
4543 let mut f = f.debug_struct("FloatingPointRef");
4544 f.field("precision", &self.precision());
4545 f.finish()
4546 }
4547 }
4548
4549 impl<'a> ::core::convert::TryFrom<FloatingPointRef<'a>> for FloatingPoint {
4550 type Error = ::planus::Error;
4551
4552 #[allow(unreachable_code)]
4553 fn try_from(value: FloatingPointRef<'a>) -> ::planus::Result<Self> {
4554 ::core::result::Result::Ok(Self {
4555 precision: ::core::convert::TryInto::try_into(value.precision()?)?,
4556 })
4557 }
4558 }
4559
4560 impl<'a> ::planus::TableRead<'a> for FloatingPointRef<'a> {
4561 #[inline]
4562 fn from_buffer(
4563 buffer: ::planus::SliceWithStartOffset<'a>,
4564 offset: usize,
4565 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
4566 {
4567 ::core::result::Result::Ok(Self(
4568 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
4569 ))
4570 }
4571 }
4572
4573 impl<'a> ::planus::VectorReadInner<'a> for FloatingPointRef<'a> {
4574 type Error = ::planus::Error;
4575 const STRIDE: usize = 4;
4576
4577 unsafe fn from_buffer(
4578 buffer: ::planus::SliceWithStartOffset<'a>,
4579 offset: usize,
4580 ) -> ::planus::Result<Self> {
4581 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
4582 error_kind.with_error_location(
4583 "[FloatingPointRef]",
4584 "get",
4585 buffer.offset_from_start,
4586 )
4587 })
4588 }
4589 }
4590
4591 /// # Safety
4592 /// The planus compiler generates implementations that initialize
4593 /// the bytes in `write_values`.
4594 unsafe impl ::planus::VectorWrite<::planus::Offset<FloatingPoint>> for FloatingPoint {
4595 type Value = ::planus::Offset<FloatingPoint>;
4596 const STRIDE: usize = 4;
4597 #[inline]
4598 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
4599 ::planus::WriteAs::prepare(self, builder)
4600 }
4601
4602 #[inline]
4603 unsafe fn write_values(
4604 values: &[::planus::Offset<FloatingPoint>],
4605 bytes: *mut ::core::mem::MaybeUninit<u8>,
4606 buffer_position: u32,
4607 ) {
4608 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
4609 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
4610 ::planus::WriteAsPrimitive::write(
4611 v,
4612 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
4613 buffer_position - (Self::STRIDE * i) as u32,
4614 );
4615 }
4616 }
4617 }
4618
4619 impl<'a> ::planus::ReadAsRoot<'a> for FloatingPointRef<'a> {
4620 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
4621 ::planus::TableRead::from_buffer(
4622 ::planus::SliceWithStartOffset {
4623 buffer: slice,
4624 offset_from_start: 0,
4625 },
4626 0,
4627 )
4628 .map_err(|error_kind| {
4629 error_kind.with_error_location(
4630 "[FloatingPointRef]",
4631 "read_as_root",
4632 0,
4633 )
4634 })
4635 }
4636 }
4637
4638 /// Unicode with UTF-8 encoding
4639 ///
4640 /// Generated from these locations:
4641 /// * Table `Utf8` in the file `Schema.fbs:171`
4642 #[derive(
4643 Clone,
4644 Debug,
4645 PartialEq,
4646 PartialOrd,
4647 Eq,
4648 Ord,
4649 Hash,
4650 ::serde::Serialize,
4651 ::serde::Deserialize,
4652 )]
4653 pub struct Utf8 {}
4654
4655 #[allow(clippy::derivable_impls)]
4656 impl ::core::default::Default for Utf8 {
4657 fn default() -> Self {
4658 Self {}
4659 }
4660 }
4661
4662 impl Utf8 {
4663 /// Creates a [Utf8Builder] for serializing an instance of this table.
4664 #[inline]
4665 pub fn builder() -> Utf8Builder<()> {
4666 Utf8Builder(())
4667 }
4668
4669 #[allow(clippy::too_many_arguments)]
4670 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
4671 let table_writer: ::planus::table_writer::TableWriter<4> =
4672 ::core::default::Default::default();
4673 unsafe {
4674 table_writer.finish(builder, |_table_writer| {});
4675 }
4676 builder.current_offset()
4677 }
4678 }
4679
4680 impl ::planus::WriteAs<::planus::Offset<Utf8>> for Utf8 {
4681 type Prepared = ::planus::Offset<Self>;
4682
4683 #[inline]
4684 fn prepare(
4685 &self,
4686 builder: &mut ::planus::Builder,
4687 ) -> ::planus::Offset<Utf8> {
4688 ::planus::WriteAsOffset::prepare(self, builder)
4689 }
4690 }
4691
4692 impl ::planus::WriteAsOptional<::planus::Offset<Utf8>> for Utf8 {
4693 type Prepared = ::planus::Offset<Self>;
4694
4695 #[inline]
4696 fn prepare(
4697 &self,
4698 builder: &mut ::planus::Builder,
4699 ) -> ::core::option::Option<::planus::Offset<Utf8>>
4700 {
4701 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4702 self, builder,
4703 ))
4704 }
4705 }
4706
4707 impl ::planus::WriteAsOffset<Utf8> for Utf8 {
4708 #[inline]
4709 fn prepare(
4710 &self,
4711 builder: &mut ::planus::Builder,
4712 ) -> ::planus::Offset<Utf8> {
4713 Utf8::create(builder)
4714 }
4715 }
4716
4717 /// Builder for serializing an instance of the [Utf8] type.
4718 ///
4719 /// Can be created using the [Utf8::builder] method.
4720 #[derive(Debug)]
4721 #[must_use]
4722 pub struct Utf8Builder<State>(State);
4723
4724 impl Utf8Builder<()> {
4725 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Utf8].
4726 #[inline]
4727 pub fn finish(
4728 self,
4729 builder: &mut ::planus::Builder,
4730 ) -> ::planus::Offset<Utf8>
4731 where
4732 Self: ::planus::WriteAsOffset<Utf8>,
4733 {
4734 ::planus::WriteAsOffset::prepare(&self, builder)
4735 }
4736 }
4737
4738 impl ::planus::WriteAs<::planus::Offset<Utf8>> for Utf8Builder<()> {
4739 type Prepared = ::planus::Offset<Utf8>;
4740
4741 #[inline]
4742 fn prepare(
4743 &self,
4744 builder: &mut ::planus::Builder,
4745 ) -> ::planus::Offset<Utf8> {
4746 ::planus::WriteAsOffset::prepare(self, builder)
4747 }
4748 }
4749
4750 impl ::planus::WriteAsOptional<::planus::Offset<Utf8>> for Utf8Builder<()> {
4751 type Prepared = ::planus::Offset<Utf8>;
4752
4753 #[inline]
4754 fn prepare(
4755 &self,
4756 builder: &mut ::planus::Builder,
4757 ) -> ::core::option::Option<::planus::Offset<Utf8>>
4758 {
4759 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4760 self, builder,
4761 ))
4762 }
4763 }
4764
4765 impl ::planus::WriteAsOffset<Utf8> for Utf8Builder<()> {
4766 #[inline]
4767 fn prepare(
4768 &self,
4769 builder: &mut ::planus::Builder,
4770 ) -> ::planus::Offset<Utf8> {
4771 Utf8::create(builder)
4772 }
4773 }
4774
4775 /// Reference to a deserialized [Utf8].
4776 #[derive(Copy, Clone)]
4777 pub struct Utf8Ref<'a>(::planus::table_reader::Table<'a>);
4778
4779 impl<'a> Utf8Ref<'a> {}
4780
4781 impl<'a> ::core::fmt::Debug for Utf8Ref<'a> {
4782 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
4783 let mut f = f.debug_struct("Utf8Ref");
4784
4785 f.finish()
4786 }
4787 }
4788
4789 impl<'a> ::core::convert::TryFrom<Utf8Ref<'a>> for Utf8 {
4790 type Error = ::planus::Error;
4791
4792 fn try_from(_value: Utf8Ref<'a>) -> ::planus::Result<Self> {
4793 ::core::result::Result::Ok(Self {})
4794 }
4795 }
4796
4797 impl<'a> ::planus::TableRead<'a> for Utf8Ref<'a> {
4798 #[inline]
4799 fn from_buffer(
4800 buffer: ::planus::SliceWithStartOffset<'a>,
4801 offset: usize,
4802 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
4803 {
4804 ::core::result::Result::Ok(Self(
4805 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
4806 ))
4807 }
4808 }
4809
4810 impl<'a> ::planus::VectorReadInner<'a> for Utf8Ref<'a> {
4811 type Error = ::planus::Error;
4812 const STRIDE: usize = 4;
4813
4814 unsafe fn from_buffer(
4815 buffer: ::planus::SliceWithStartOffset<'a>,
4816 offset: usize,
4817 ) -> ::planus::Result<Self> {
4818 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
4819 error_kind.with_error_location(
4820 "[Utf8Ref]",
4821 "get",
4822 buffer.offset_from_start,
4823 )
4824 })
4825 }
4826 }
4827
4828 /// # Safety
4829 /// The planus compiler generates implementations that initialize
4830 /// the bytes in `write_values`.
4831 unsafe impl ::planus::VectorWrite<::planus::Offset<Utf8>> for Utf8 {
4832 type Value = ::planus::Offset<Utf8>;
4833 const STRIDE: usize = 4;
4834 #[inline]
4835 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
4836 ::planus::WriteAs::prepare(self, builder)
4837 }
4838
4839 #[inline]
4840 unsafe fn write_values(
4841 values: &[::planus::Offset<Utf8>],
4842 bytes: *mut ::core::mem::MaybeUninit<u8>,
4843 buffer_position: u32,
4844 ) {
4845 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
4846 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
4847 ::planus::WriteAsPrimitive::write(
4848 v,
4849 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
4850 buffer_position - (Self::STRIDE * i) as u32,
4851 );
4852 }
4853 }
4854 }
4855
4856 impl<'a> ::planus::ReadAsRoot<'a> for Utf8Ref<'a> {
4857 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
4858 ::planus::TableRead::from_buffer(
4859 ::planus::SliceWithStartOffset {
4860 buffer: slice,
4861 offset_from_start: 0,
4862 },
4863 0,
4864 )
4865 .map_err(|error_kind| {
4866 error_kind.with_error_location("[Utf8Ref]", "read_as_root", 0)
4867 })
4868 }
4869 }
4870
4871 /// Opaque binary data
4872 ///
4873 /// Generated from these locations:
4874 /// * Table `Binary` in the file `Schema.fbs:175`
4875 #[derive(
4876 Clone,
4877 Debug,
4878 PartialEq,
4879 PartialOrd,
4880 Eq,
4881 Ord,
4882 Hash,
4883 ::serde::Serialize,
4884 ::serde::Deserialize,
4885 )]
4886 pub struct Binary {}
4887
4888 #[allow(clippy::derivable_impls)]
4889 impl ::core::default::Default for Binary {
4890 fn default() -> Self {
4891 Self {}
4892 }
4893 }
4894
4895 impl Binary {
4896 /// Creates a [BinaryBuilder] for serializing an instance of this table.
4897 #[inline]
4898 pub fn builder() -> BinaryBuilder<()> {
4899 BinaryBuilder(())
4900 }
4901
4902 #[allow(clippy::too_many_arguments)]
4903 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
4904 let table_writer: ::planus::table_writer::TableWriter<4> =
4905 ::core::default::Default::default();
4906 unsafe {
4907 table_writer.finish(builder, |_table_writer| {});
4908 }
4909 builder.current_offset()
4910 }
4911 }
4912
4913 impl ::planus::WriteAs<::planus::Offset<Binary>> for Binary {
4914 type Prepared = ::planus::Offset<Self>;
4915
4916 #[inline]
4917 fn prepare(
4918 &self,
4919 builder: &mut ::planus::Builder,
4920 ) -> ::planus::Offset<Binary> {
4921 ::planus::WriteAsOffset::prepare(self, builder)
4922 }
4923 }
4924
4925 impl ::planus::WriteAsOptional<::planus::Offset<Binary>> for Binary {
4926 type Prepared = ::planus::Offset<Self>;
4927
4928 #[inline]
4929 fn prepare(
4930 &self,
4931 builder: &mut ::planus::Builder,
4932 ) -> ::core::option::Option<::planus::Offset<Binary>>
4933 {
4934 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4935 self, builder,
4936 ))
4937 }
4938 }
4939
4940 impl ::planus::WriteAsOffset<Binary> for Binary {
4941 #[inline]
4942 fn prepare(
4943 &self,
4944 builder: &mut ::planus::Builder,
4945 ) -> ::planus::Offset<Binary> {
4946 Binary::create(builder)
4947 }
4948 }
4949
4950 /// Builder for serializing an instance of the [Binary] type.
4951 ///
4952 /// Can be created using the [Binary::builder] method.
4953 #[derive(Debug)]
4954 #[must_use]
4955 pub struct BinaryBuilder<State>(State);
4956
4957 impl BinaryBuilder<()> {
4958 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary].
4959 #[inline]
4960 pub fn finish(
4961 self,
4962 builder: &mut ::planus::Builder,
4963 ) -> ::planus::Offset<Binary>
4964 where
4965 Self: ::planus::WriteAsOffset<Binary>,
4966 {
4967 ::planus::WriteAsOffset::prepare(&self, builder)
4968 }
4969 }
4970
4971 impl ::planus::WriteAs<::planus::Offset<Binary>> for BinaryBuilder<()> {
4972 type Prepared = ::planus::Offset<Binary>;
4973
4974 #[inline]
4975 fn prepare(
4976 &self,
4977 builder: &mut ::planus::Builder,
4978 ) -> ::planus::Offset<Binary> {
4979 ::planus::WriteAsOffset::prepare(self, builder)
4980 }
4981 }
4982
4983 impl ::planus::WriteAsOptional<::planus::Offset<Binary>> for BinaryBuilder<()> {
4984 type Prepared = ::planus::Offset<Binary>;
4985
4986 #[inline]
4987 fn prepare(
4988 &self,
4989 builder: &mut ::planus::Builder,
4990 ) -> ::core::option::Option<::planus::Offset<Binary>>
4991 {
4992 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
4993 self, builder,
4994 ))
4995 }
4996 }
4997
4998 impl ::planus::WriteAsOffset<Binary> for BinaryBuilder<()> {
4999 #[inline]
5000 fn prepare(
5001 &self,
5002 builder: &mut ::planus::Builder,
5003 ) -> ::planus::Offset<Binary> {
5004 Binary::create(builder)
5005 }
5006 }
5007
5008 /// Reference to a deserialized [Binary].
5009 #[derive(Copy, Clone)]
5010 pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>);
5011
5012 impl<'a> BinaryRef<'a> {}
5013
5014 impl<'a> ::core::fmt::Debug for BinaryRef<'a> {
5015 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
5016 let mut f = f.debug_struct("BinaryRef");
5017
5018 f.finish()
5019 }
5020 }
5021
5022 impl<'a> ::core::convert::TryFrom<BinaryRef<'a>> for Binary {
5023 type Error = ::planus::Error;
5024
5025 fn try_from(_value: BinaryRef<'a>) -> ::planus::Result<Self> {
5026 ::core::result::Result::Ok(Self {})
5027 }
5028 }
5029
5030 impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> {
5031 #[inline]
5032 fn from_buffer(
5033 buffer: ::planus::SliceWithStartOffset<'a>,
5034 offset: usize,
5035 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
5036 {
5037 ::core::result::Result::Ok(Self(
5038 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
5039 ))
5040 }
5041 }
5042
5043 impl<'a> ::planus::VectorReadInner<'a> for BinaryRef<'a> {
5044 type Error = ::planus::Error;
5045 const STRIDE: usize = 4;
5046
5047 unsafe fn from_buffer(
5048 buffer: ::planus::SliceWithStartOffset<'a>,
5049 offset: usize,
5050 ) -> ::planus::Result<Self> {
5051 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
5052 error_kind.with_error_location(
5053 "[BinaryRef]",
5054 "get",
5055 buffer.offset_from_start,
5056 )
5057 })
5058 }
5059 }
5060
5061 /// # Safety
5062 /// The planus compiler generates implementations that initialize
5063 /// the bytes in `write_values`.
5064 unsafe impl ::planus::VectorWrite<::planus::Offset<Binary>> for Binary {
5065 type Value = ::planus::Offset<Binary>;
5066 const STRIDE: usize = 4;
5067 #[inline]
5068 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
5069 ::planus::WriteAs::prepare(self, builder)
5070 }
5071
5072 #[inline]
5073 unsafe fn write_values(
5074 values: &[::planus::Offset<Binary>],
5075 bytes: *mut ::core::mem::MaybeUninit<u8>,
5076 buffer_position: u32,
5077 ) {
5078 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
5079 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
5080 ::planus::WriteAsPrimitive::write(
5081 v,
5082 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
5083 buffer_position - (Self::STRIDE * i) as u32,
5084 );
5085 }
5086 }
5087 }
5088
5089 impl<'a> ::planus::ReadAsRoot<'a> for BinaryRef<'a> {
5090 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
5091 ::planus::TableRead::from_buffer(
5092 ::planus::SliceWithStartOffset {
5093 buffer: slice,
5094 offset_from_start: 0,
5095 },
5096 0,
5097 )
5098 .map_err(|error_kind| {
5099 error_kind.with_error_location("[BinaryRef]", "read_as_root", 0)
5100 })
5101 }
5102 }
5103
5104 /// Same as Utf8, but with 64-bit offsets, allowing to represent
5105 /// extremely large data values.
5106 ///
5107 /// Generated from these locations:
5108 /// * Table `LargeUtf8` in the file `Schema.fbs:180`
5109 #[derive(
5110 Clone,
5111 Debug,
5112 PartialEq,
5113 PartialOrd,
5114 Eq,
5115 Ord,
5116 Hash,
5117 ::serde::Serialize,
5118 ::serde::Deserialize,
5119 )]
5120 pub struct LargeUtf8 {}
5121
5122 #[allow(clippy::derivable_impls)]
5123 impl ::core::default::Default for LargeUtf8 {
5124 fn default() -> Self {
5125 Self {}
5126 }
5127 }
5128
5129 impl LargeUtf8 {
5130 /// Creates a [LargeUtf8Builder] for serializing an instance of this table.
5131 #[inline]
5132 pub fn builder() -> LargeUtf8Builder<()> {
5133 LargeUtf8Builder(())
5134 }
5135
5136 #[allow(clippy::too_many_arguments)]
5137 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
5138 let table_writer: ::planus::table_writer::TableWriter<4> =
5139 ::core::default::Default::default();
5140 unsafe {
5141 table_writer.finish(builder, |_table_writer| {});
5142 }
5143 builder.current_offset()
5144 }
5145 }
5146
5147 impl ::planus::WriteAs<::planus::Offset<LargeUtf8>> for LargeUtf8 {
5148 type Prepared = ::planus::Offset<Self>;
5149
5150 #[inline]
5151 fn prepare(
5152 &self,
5153 builder: &mut ::planus::Builder,
5154 ) -> ::planus::Offset<LargeUtf8> {
5155 ::planus::WriteAsOffset::prepare(self, builder)
5156 }
5157 }
5158
5159 impl ::planus::WriteAsOptional<::planus::Offset<LargeUtf8>> for LargeUtf8 {
5160 type Prepared = ::planus::Offset<Self>;
5161
5162 #[inline]
5163 fn prepare(
5164 &self,
5165 builder: &mut ::planus::Builder,
5166 ) -> ::core::option::Option<::planus::Offset<LargeUtf8>>
5167 {
5168 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5169 self, builder,
5170 ))
5171 }
5172 }
5173
5174 impl ::planus::WriteAsOffset<LargeUtf8> for LargeUtf8 {
5175 #[inline]
5176 fn prepare(
5177 &self,
5178 builder: &mut ::planus::Builder,
5179 ) -> ::planus::Offset<LargeUtf8> {
5180 LargeUtf8::create(builder)
5181 }
5182 }
5183
5184 /// Builder for serializing an instance of the [LargeUtf8] type.
5185 ///
5186 /// Can be created using the [LargeUtf8::builder] method.
5187 #[derive(Debug)]
5188 #[must_use]
5189 pub struct LargeUtf8Builder<State>(State);
5190
5191 impl LargeUtf8Builder<()> {
5192 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [LargeUtf8].
5193 #[inline]
5194 pub fn finish(
5195 self,
5196 builder: &mut ::planus::Builder,
5197 ) -> ::planus::Offset<LargeUtf8>
5198 where
5199 Self: ::planus::WriteAsOffset<LargeUtf8>,
5200 {
5201 ::planus::WriteAsOffset::prepare(&self, builder)
5202 }
5203 }
5204
5205 impl ::planus::WriteAs<::planus::Offset<LargeUtf8>> for LargeUtf8Builder<()> {
5206 type Prepared = ::planus::Offset<LargeUtf8>;
5207
5208 #[inline]
5209 fn prepare(
5210 &self,
5211 builder: &mut ::planus::Builder,
5212 ) -> ::planus::Offset<LargeUtf8> {
5213 ::planus::WriteAsOffset::prepare(self, builder)
5214 }
5215 }
5216
5217 impl ::planus::WriteAsOptional<::planus::Offset<LargeUtf8>> for LargeUtf8Builder<()> {
5218 type Prepared = ::planus::Offset<LargeUtf8>;
5219
5220 #[inline]
5221 fn prepare(
5222 &self,
5223 builder: &mut ::planus::Builder,
5224 ) -> ::core::option::Option<::planus::Offset<LargeUtf8>>
5225 {
5226 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5227 self, builder,
5228 ))
5229 }
5230 }
5231
5232 impl ::planus::WriteAsOffset<LargeUtf8> for LargeUtf8Builder<()> {
5233 #[inline]
5234 fn prepare(
5235 &self,
5236 builder: &mut ::planus::Builder,
5237 ) -> ::planus::Offset<LargeUtf8> {
5238 LargeUtf8::create(builder)
5239 }
5240 }
5241
5242 /// Reference to a deserialized [LargeUtf8].
5243 #[derive(Copy, Clone)]
5244 pub struct LargeUtf8Ref<'a>(::planus::table_reader::Table<'a>);
5245
5246 impl<'a> LargeUtf8Ref<'a> {}
5247
5248 impl<'a> ::core::fmt::Debug for LargeUtf8Ref<'a> {
5249 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
5250 let mut f = f.debug_struct("LargeUtf8Ref");
5251
5252 f.finish()
5253 }
5254 }
5255
5256 impl<'a> ::core::convert::TryFrom<LargeUtf8Ref<'a>> for LargeUtf8 {
5257 type Error = ::planus::Error;
5258
5259 fn try_from(_value: LargeUtf8Ref<'a>) -> ::planus::Result<Self> {
5260 ::core::result::Result::Ok(Self {})
5261 }
5262 }
5263
5264 impl<'a> ::planus::TableRead<'a> for LargeUtf8Ref<'a> {
5265 #[inline]
5266 fn from_buffer(
5267 buffer: ::planus::SliceWithStartOffset<'a>,
5268 offset: usize,
5269 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
5270 {
5271 ::core::result::Result::Ok(Self(
5272 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
5273 ))
5274 }
5275 }
5276
5277 impl<'a> ::planus::VectorReadInner<'a> for LargeUtf8Ref<'a> {
5278 type Error = ::planus::Error;
5279 const STRIDE: usize = 4;
5280
5281 unsafe fn from_buffer(
5282 buffer: ::planus::SliceWithStartOffset<'a>,
5283 offset: usize,
5284 ) -> ::planus::Result<Self> {
5285 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
5286 error_kind.with_error_location(
5287 "[LargeUtf8Ref]",
5288 "get",
5289 buffer.offset_from_start,
5290 )
5291 })
5292 }
5293 }
5294
5295 /// # Safety
5296 /// The planus compiler generates implementations that initialize
5297 /// the bytes in `write_values`.
5298 unsafe impl ::planus::VectorWrite<::planus::Offset<LargeUtf8>> for LargeUtf8 {
5299 type Value = ::planus::Offset<LargeUtf8>;
5300 const STRIDE: usize = 4;
5301 #[inline]
5302 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
5303 ::planus::WriteAs::prepare(self, builder)
5304 }
5305
5306 #[inline]
5307 unsafe fn write_values(
5308 values: &[::planus::Offset<LargeUtf8>],
5309 bytes: *mut ::core::mem::MaybeUninit<u8>,
5310 buffer_position: u32,
5311 ) {
5312 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
5313 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
5314 ::planus::WriteAsPrimitive::write(
5315 v,
5316 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
5317 buffer_position - (Self::STRIDE * i) as u32,
5318 );
5319 }
5320 }
5321 }
5322
5323 impl<'a> ::planus::ReadAsRoot<'a> for LargeUtf8Ref<'a> {
5324 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
5325 ::planus::TableRead::from_buffer(
5326 ::planus::SliceWithStartOffset {
5327 buffer: slice,
5328 offset_from_start: 0,
5329 },
5330 0,
5331 )
5332 .map_err(|error_kind| {
5333 error_kind.with_error_location("[LargeUtf8Ref]", "read_as_root", 0)
5334 })
5335 }
5336 }
5337
5338 /// Same as Binary, but with 64-bit offsets, allowing to represent
5339 /// extremely large data values.
5340 ///
5341 /// Generated from these locations:
5342 /// * Table `LargeBinary` in the file `Schema.fbs:185`
5343 #[derive(
5344 Clone,
5345 Debug,
5346 PartialEq,
5347 PartialOrd,
5348 Eq,
5349 Ord,
5350 Hash,
5351 ::serde::Serialize,
5352 ::serde::Deserialize,
5353 )]
5354 pub struct LargeBinary {}
5355
5356 #[allow(clippy::derivable_impls)]
5357 impl ::core::default::Default for LargeBinary {
5358 fn default() -> Self {
5359 Self {}
5360 }
5361 }
5362
5363 impl LargeBinary {
5364 /// Creates a [LargeBinaryBuilder] for serializing an instance of this table.
5365 #[inline]
5366 pub fn builder() -> LargeBinaryBuilder<()> {
5367 LargeBinaryBuilder(())
5368 }
5369
5370 #[allow(clippy::too_many_arguments)]
5371 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
5372 let table_writer: ::planus::table_writer::TableWriter<4> =
5373 ::core::default::Default::default();
5374 unsafe {
5375 table_writer.finish(builder, |_table_writer| {});
5376 }
5377 builder.current_offset()
5378 }
5379 }
5380
5381 impl ::planus::WriteAs<::planus::Offset<LargeBinary>> for LargeBinary {
5382 type Prepared = ::planus::Offset<Self>;
5383
5384 #[inline]
5385 fn prepare(
5386 &self,
5387 builder: &mut ::planus::Builder,
5388 ) -> ::planus::Offset<LargeBinary> {
5389 ::planus::WriteAsOffset::prepare(self, builder)
5390 }
5391 }
5392
5393 impl ::planus::WriteAsOptional<::planus::Offset<LargeBinary>> for LargeBinary {
5394 type Prepared = ::planus::Offset<Self>;
5395
5396 #[inline]
5397 fn prepare(
5398 &self,
5399 builder: &mut ::planus::Builder,
5400 ) -> ::core::option::Option<::planus::Offset<LargeBinary>>
5401 {
5402 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5403 self, builder,
5404 ))
5405 }
5406 }
5407
5408 impl ::planus::WriteAsOffset<LargeBinary> for LargeBinary {
5409 #[inline]
5410 fn prepare(
5411 &self,
5412 builder: &mut ::planus::Builder,
5413 ) -> ::planus::Offset<LargeBinary> {
5414 LargeBinary::create(builder)
5415 }
5416 }
5417
5418 /// Builder for serializing an instance of the [LargeBinary] type.
5419 ///
5420 /// Can be created using the [LargeBinary::builder] method.
5421 #[derive(Debug)]
5422 #[must_use]
5423 pub struct LargeBinaryBuilder<State>(State);
5424
5425 impl LargeBinaryBuilder<()> {
5426 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [LargeBinary].
5427 #[inline]
5428 pub fn finish(
5429 self,
5430 builder: &mut ::planus::Builder,
5431 ) -> ::planus::Offset<LargeBinary>
5432 where
5433 Self: ::planus::WriteAsOffset<LargeBinary>,
5434 {
5435 ::planus::WriteAsOffset::prepare(&self, builder)
5436 }
5437 }
5438
5439 impl ::planus::WriteAs<::planus::Offset<LargeBinary>> for LargeBinaryBuilder<()> {
5440 type Prepared = ::planus::Offset<LargeBinary>;
5441
5442 #[inline]
5443 fn prepare(
5444 &self,
5445 builder: &mut ::planus::Builder,
5446 ) -> ::planus::Offset<LargeBinary> {
5447 ::planus::WriteAsOffset::prepare(self, builder)
5448 }
5449 }
5450
5451 impl ::planus::WriteAsOptional<::planus::Offset<LargeBinary>> for LargeBinaryBuilder<()> {
5452 type Prepared = ::planus::Offset<LargeBinary>;
5453
5454 #[inline]
5455 fn prepare(
5456 &self,
5457 builder: &mut ::planus::Builder,
5458 ) -> ::core::option::Option<::planus::Offset<LargeBinary>>
5459 {
5460 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5461 self, builder,
5462 ))
5463 }
5464 }
5465
5466 impl ::planus::WriteAsOffset<LargeBinary> for LargeBinaryBuilder<()> {
5467 #[inline]
5468 fn prepare(
5469 &self,
5470 builder: &mut ::planus::Builder,
5471 ) -> ::planus::Offset<LargeBinary> {
5472 LargeBinary::create(builder)
5473 }
5474 }
5475
5476 /// Reference to a deserialized [LargeBinary].
5477 #[derive(Copy, Clone)]
5478 pub struct LargeBinaryRef<'a>(::planus::table_reader::Table<'a>);
5479
5480 impl<'a> LargeBinaryRef<'a> {}
5481
5482 impl<'a> ::core::fmt::Debug for LargeBinaryRef<'a> {
5483 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
5484 let mut f = f.debug_struct("LargeBinaryRef");
5485
5486 f.finish()
5487 }
5488 }
5489
5490 impl<'a> ::core::convert::TryFrom<LargeBinaryRef<'a>> for LargeBinary {
5491 type Error = ::planus::Error;
5492
5493 fn try_from(_value: LargeBinaryRef<'a>) -> ::planus::Result<Self> {
5494 ::core::result::Result::Ok(Self {})
5495 }
5496 }
5497
5498 impl<'a> ::planus::TableRead<'a> for LargeBinaryRef<'a> {
5499 #[inline]
5500 fn from_buffer(
5501 buffer: ::planus::SliceWithStartOffset<'a>,
5502 offset: usize,
5503 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
5504 {
5505 ::core::result::Result::Ok(Self(
5506 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
5507 ))
5508 }
5509 }
5510
5511 impl<'a> ::planus::VectorReadInner<'a> for LargeBinaryRef<'a> {
5512 type Error = ::planus::Error;
5513 const STRIDE: usize = 4;
5514
5515 unsafe fn from_buffer(
5516 buffer: ::planus::SliceWithStartOffset<'a>,
5517 offset: usize,
5518 ) -> ::planus::Result<Self> {
5519 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
5520 error_kind.with_error_location(
5521 "[LargeBinaryRef]",
5522 "get",
5523 buffer.offset_from_start,
5524 )
5525 })
5526 }
5527 }
5528
5529 /// # Safety
5530 /// The planus compiler generates implementations that initialize
5531 /// the bytes in `write_values`.
5532 unsafe impl ::planus::VectorWrite<::planus::Offset<LargeBinary>> for LargeBinary {
5533 type Value = ::planus::Offset<LargeBinary>;
5534 const STRIDE: usize = 4;
5535 #[inline]
5536 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
5537 ::planus::WriteAs::prepare(self, builder)
5538 }
5539
5540 #[inline]
5541 unsafe fn write_values(
5542 values: &[::planus::Offset<LargeBinary>],
5543 bytes: *mut ::core::mem::MaybeUninit<u8>,
5544 buffer_position: u32,
5545 ) {
5546 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
5547 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
5548 ::planus::WriteAsPrimitive::write(
5549 v,
5550 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
5551 buffer_position - (Self::STRIDE * i) as u32,
5552 );
5553 }
5554 }
5555 }
5556
5557 impl<'a> ::planus::ReadAsRoot<'a> for LargeBinaryRef<'a> {
5558 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
5559 ::planus::TableRead::from_buffer(
5560 ::planus::SliceWithStartOffset {
5561 buffer: slice,
5562 offset_from_start: 0,
5563 },
5564 0,
5565 )
5566 .map_err(|error_kind| {
5567 error_kind.with_error_location(
5568 "[LargeBinaryRef]",
5569 "read_as_root",
5570 0,
5571 )
5572 })
5573 }
5574 }
5575
5576 /// Logically the same as Utf8, but the internal representation uses a view
5577 /// struct that contains the string length and either the string's entire data
5578 /// inline (for small strings) or an inlined prefix, an index of another buffer,
5579 /// and an offset pointing to a slice in that buffer (for non-small strings).
5580 ///
5581 /// Since it uses a variable number of data buffers, each Field with this type
5582 /// must have a corresponding entry in `variadicBufferCounts`.
5583 ///
5584 /// Generated from these locations:
5585 /// * Table `Utf8View` in the file `Schema.fbs:195`
5586 #[derive(
5587 Clone,
5588 Debug,
5589 PartialEq,
5590 PartialOrd,
5591 Eq,
5592 Ord,
5593 Hash,
5594 ::serde::Serialize,
5595 ::serde::Deserialize,
5596 )]
5597 pub struct Utf8View {}
5598
5599 #[allow(clippy::derivable_impls)]
5600 impl ::core::default::Default for Utf8View {
5601 fn default() -> Self {
5602 Self {}
5603 }
5604 }
5605
5606 impl Utf8View {
5607 /// Creates a [Utf8ViewBuilder] for serializing an instance of this table.
5608 #[inline]
5609 pub fn builder() -> Utf8ViewBuilder<()> {
5610 Utf8ViewBuilder(())
5611 }
5612
5613 #[allow(clippy::too_many_arguments)]
5614 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
5615 let table_writer: ::planus::table_writer::TableWriter<4> =
5616 ::core::default::Default::default();
5617 unsafe {
5618 table_writer.finish(builder, |_table_writer| {});
5619 }
5620 builder.current_offset()
5621 }
5622 }
5623
5624 impl ::planus::WriteAs<::planus::Offset<Utf8View>> for Utf8View {
5625 type Prepared = ::planus::Offset<Self>;
5626
5627 #[inline]
5628 fn prepare(
5629 &self,
5630 builder: &mut ::planus::Builder,
5631 ) -> ::planus::Offset<Utf8View> {
5632 ::planus::WriteAsOffset::prepare(self, builder)
5633 }
5634 }
5635
5636 impl ::planus::WriteAsOptional<::planus::Offset<Utf8View>> for Utf8View {
5637 type Prepared = ::planus::Offset<Self>;
5638
5639 #[inline]
5640 fn prepare(
5641 &self,
5642 builder: &mut ::planus::Builder,
5643 ) -> ::core::option::Option<::planus::Offset<Utf8View>>
5644 {
5645 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5646 self, builder,
5647 ))
5648 }
5649 }
5650
5651 impl ::planus::WriteAsOffset<Utf8View> for Utf8View {
5652 #[inline]
5653 fn prepare(
5654 &self,
5655 builder: &mut ::planus::Builder,
5656 ) -> ::planus::Offset<Utf8View> {
5657 Utf8View::create(builder)
5658 }
5659 }
5660
5661 /// Builder for serializing an instance of the [Utf8View] type.
5662 ///
5663 /// Can be created using the [Utf8View::builder] method.
5664 #[derive(Debug)]
5665 #[must_use]
5666 pub struct Utf8ViewBuilder<State>(State);
5667
5668 impl Utf8ViewBuilder<()> {
5669 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Utf8View].
5670 #[inline]
5671 pub fn finish(
5672 self,
5673 builder: &mut ::planus::Builder,
5674 ) -> ::planus::Offset<Utf8View>
5675 where
5676 Self: ::planus::WriteAsOffset<Utf8View>,
5677 {
5678 ::planus::WriteAsOffset::prepare(&self, builder)
5679 }
5680 }
5681
5682 impl ::planus::WriteAs<::planus::Offset<Utf8View>> for Utf8ViewBuilder<()> {
5683 type Prepared = ::planus::Offset<Utf8View>;
5684
5685 #[inline]
5686 fn prepare(
5687 &self,
5688 builder: &mut ::planus::Builder,
5689 ) -> ::planus::Offset<Utf8View> {
5690 ::planus::WriteAsOffset::prepare(self, builder)
5691 }
5692 }
5693
5694 impl ::planus::WriteAsOptional<::planus::Offset<Utf8View>> for Utf8ViewBuilder<()> {
5695 type Prepared = ::planus::Offset<Utf8View>;
5696
5697 #[inline]
5698 fn prepare(
5699 &self,
5700 builder: &mut ::planus::Builder,
5701 ) -> ::core::option::Option<::planus::Offset<Utf8View>>
5702 {
5703 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5704 self, builder,
5705 ))
5706 }
5707 }
5708
5709 impl ::planus::WriteAsOffset<Utf8View> for Utf8ViewBuilder<()> {
5710 #[inline]
5711 fn prepare(
5712 &self,
5713 builder: &mut ::planus::Builder,
5714 ) -> ::planus::Offset<Utf8View> {
5715 Utf8View::create(builder)
5716 }
5717 }
5718
5719 /// Reference to a deserialized [Utf8View].
5720 #[derive(Copy, Clone)]
5721 pub struct Utf8ViewRef<'a>(::planus::table_reader::Table<'a>);
5722
5723 impl<'a> Utf8ViewRef<'a> {}
5724
5725 impl<'a> ::core::fmt::Debug for Utf8ViewRef<'a> {
5726 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
5727 let mut f = f.debug_struct("Utf8ViewRef");
5728
5729 f.finish()
5730 }
5731 }
5732
5733 impl<'a> ::core::convert::TryFrom<Utf8ViewRef<'a>> for Utf8View {
5734 type Error = ::planus::Error;
5735
5736 fn try_from(_value: Utf8ViewRef<'a>) -> ::planus::Result<Self> {
5737 ::core::result::Result::Ok(Self {})
5738 }
5739 }
5740
5741 impl<'a> ::planus::TableRead<'a> for Utf8ViewRef<'a> {
5742 #[inline]
5743 fn from_buffer(
5744 buffer: ::planus::SliceWithStartOffset<'a>,
5745 offset: usize,
5746 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
5747 {
5748 ::core::result::Result::Ok(Self(
5749 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
5750 ))
5751 }
5752 }
5753
5754 impl<'a> ::planus::VectorReadInner<'a> for Utf8ViewRef<'a> {
5755 type Error = ::planus::Error;
5756 const STRIDE: usize = 4;
5757
5758 unsafe fn from_buffer(
5759 buffer: ::planus::SliceWithStartOffset<'a>,
5760 offset: usize,
5761 ) -> ::planus::Result<Self> {
5762 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
5763 error_kind.with_error_location(
5764 "[Utf8ViewRef]",
5765 "get",
5766 buffer.offset_from_start,
5767 )
5768 })
5769 }
5770 }
5771
5772 /// # Safety
5773 /// The planus compiler generates implementations that initialize
5774 /// the bytes in `write_values`.
5775 unsafe impl ::planus::VectorWrite<::planus::Offset<Utf8View>> for Utf8View {
5776 type Value = ::planus::Offset<Utf8View>;
5777 const STRIDE: usize = 4;
5778 #[inline]
5779 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
5780 ::planus::WriteAs::prepare(self, builder)
5781 }
5782
5783 #[inline]
5784 unsafe fn write_values(
5785 values: &[::planus::Offset<Utf8View>],
5786 bytes: *mut ::core::mem::MaybeUninit<u8>,
5787 buffer_position: u32,
5788 ) {
5789 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
5790 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
5791 ::planus::WriteAsPrimitive::write(
5792 v,
5793 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
5794 buffer_position - (Self::STRIDE * i) as u32,
5795 );
5796 }
5797 }
5798 }
5799
5800 impl<'a> ::planus::ReadAsRoot<'a> for Utf8ViewRef<'a> {
5801 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
5802 ::planus::TableRead::from_buffer(
5803 ::planus::SliceWithStartOffset {
5804 buffer: slice,
5805 offset_from_start: 0,
5806 },
5807 0,
5808 )
5809 .map_err(|error_kind| {
5810 error_kind.with_error_location("[Utf8ViewRef]", "read_as_root", 0)
5811 })
5812 }
5813 }
5814
5815 /// Logically the same as Binary, but the internal representation uses a view
5816 /// struct that contains the string length and either the string's entire data
5817 /// inline (for small strings) or an inlined prefix, an index of another buffer,
5818 /// and an offset pointing to a slice in that buffer (for non-small strings).
5819 ///
5820 /// Since it uses a variable number of data buffers, each Field with this type
5821 /// must have a corresponding entry in `variadicBufferCounts`.
5822 ///
5823 /// Generated from these locations:
5824 /// * Table `BinaryView` in the file `Schema.fbs:205`
5825 #[derive(
5826 Clone,
5827 Debug,
5828 PartialEq,
5829 PartialOrd,
5830 Eq,
5831 Ord,
5832 Hash,
5833 ::serde::Serialize,
5834 ::serde::Deserialize,
5835 )]
5836 pub struct BinaryView {}
5837
5838 #[allow(clippy::derivable_impls)]
5839 impl ::core::default::Default for BinaryView {
5840 fn default() -> Self {
5841 Self {}
5842 }
5843 }
5844
5845 impl BinaryView {
5846 /// Creates a [BinaryViewBuilder] for serializing an instance of this table.
5847 #[inline]
5848 pub fn builder() -> BinaryViewBuilder<()> {
5849 BinaryViewBuilder(())
5850 }
5851
5852 #[allow(clippy::too_many_arguments)]
5853 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
5854 let table_writer: ::planus::table_writer::TableWriter<4> =
5855 ::core::default::Default::default();
5856 unsafe {
5857 table_writer.finish(builder, |_table_writer| {});
5858 }
5859 builder.current_offset()
5860 }
5861 }
5862
5863 impl ::planus::WriteAs<::planus::Offset<BinaryView>> for BinaryView {
5864 type Prepared = ::planus::Offset<Self>;
5865
5866 #[inline]
5867 fn prepare(
5868 &self,
5869 builder: &mut ::planus::Builder,
5870 ) -> ::planus::Offset<BinaryView> {
5871 ::planus::WriteAsOffset::prepare(self, builder)
5872 }
5873 }
5874
5875 impl ::planus::WriteAsOptional<::planus::Offset<BinaryView>> for BinaryView {
5876 type Prepared = ::planus::Offset<Self>;
5877
5878 #[inline]
5879 fn prepare(
5880 &self,
5881 builder: &mut ::planus::Builder,
5882 ) -> ::core::option::Option<::planus::Offset<BinaryView>>
5883 {
5884 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5885 self, builder,
5886 ))
5887 }
5888 }
5889
5890 impl ::planus::WriteAsOffset<BinaryView> for BinaryView {
5891 #[inline]
5892 fn prepare(
5893 &self,
5894 builder: &mut ::planus::Builder,
5895 ) -> ::planus::Offset<BinaryView> {
5896 BinaryView::create(builder)
5897 }
5898 }
5899
5900 /// Builder for serializing an instance of the [BinaryView] type.
5901 ///
5902 /// Can be created using the [BinaryView::builder] method.
5903 #[derive(Debug)]
5904 #[must_use]
5905 pub struct BinaryViewBuilder<State>(State);
5906
5907 impl BinaryViewBuilder<()> {
5908 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BinaryView].
5909 #[inline]
5910 pub fn finish(
5911 self,
5912 builder: &mut ::planus::Builder,
5913 ) -> ::planus::Offset<BinaryView>
5914 where
5915 Self: ::planus::WriteAsOffset<BinaryView>,
5916 {
5917 ::planus::WriteAsOffset::prepare(&self, builder)
5918 }
5919 }
5920
5921 impl ::planus::WriteAs<::planus::Offset<BinaryView>> for BinaryViewBuilder<()> {
5922 type Prepared = ::planus::Offset<BinaryView>;
5923
5924 #[inline]
5925 fn prepare(
5926 &self,
5927 builder: &mut ::planus::Builder,
5928 ) -> ::planus::Offset<BinaryView> {
5929 ::planus::WriteAsOffset::prepare(self, builder)
5930 }
5931 }
5932
5933 impl ::planus::WriteAsOptional<::planus::Offset<BinaryView>> for BinaryViewBuilder<()> {
5934 type Prepared = ::planus::Offset<BinaryView>;
5935
5936 #[inline]
5937 fn prepare(
5938 &self,
5939 builder: &mut ::planus::Builder,
5940 ) -> ::core::option::Option<::planus::Offset<BinaryView>>
5941 {
5942 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
5943 self, builder,
5944 ))
5945 }
5946 }
5947
5948 impl ::planus::WriteAsOffset<BinaryView> for BinaryViewBuilder<()> {
5949 #[inline]
5950 fn prepare(
5951 &self,
5952 builder: &mut ::planus::Builder,
5953 ) -> ::planus::Offset<BinaryView> {
5954 BinaryView::create(builder)
5955 }
5956 }
5957
5958 /// Reference to a deserialized [BinaryView].
5959 #[derive(Copy, Clone)]
5960 pub struct BinaryViewRef<'a>(::planus::table_reader::Table<'a>);
5961
5962 impl<'a> BinaryViewRef<'a> {}
5963
5964 impl<'a> ::core::fmt::Debug for BinaryViewRef<'a> {
5965 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
5966 let mut f = f.debug_struct("BinaryViewRef");
5967
5968 f.finish()
5969 }
5970 }
5971
5972 impl<'a> ::core::convert::TryFrom<BinaryViewRef<'a>> for BinaryView {
5973 type Error = ::planus::Error;
5974
5975 fn try_from(_value: BinaryViewRef<'a>) -> ::planus::Result<Self> {
5976 ::core::result::Result::Ok(Self {})
5977 }
5978 }
5979
5980 impl<'a> ::planus::TableRead<'a> for BinaryViewRef<'a> {
5981 #[inline]
5982 fn from_buffer(
5983 buffer: ::planus::SliceWithStartOffset<'a>,
5984 offset: usize,
5985 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
5986 {
5987 ::core::result::Result::Ok(Self(
5988 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
5989 ))
5990 }
5991 }
5992
5993 impl<'a> ::planus::VectorReadInner<'a> for BinaryViewRef<'a> {
5994 type Error = ::planus::Error;
5995 const STRIDE: usize = 4;
5996
5997 unsafe fn from_buffer(
5998 buffer: ::planus::SliceWithStartOffset<'a>,
5999 offset: usize,
6000 ) -> ::planus::Result<Self> {
6001 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
6002 error_kind.with_error_location(
6003 "[BinaryViewRef]",
6004 "get",
6005 buffer.offset_from_start,
6006 )
6007 })
6008 }
6009 }
6010
6011 /// # Safety
6012 /// The planus compiler generates implementations that initialize
6013 /// the bytes in `write_values`.
6014 unsafe impl ::planus::VectorWrite<::planus::Offset<BinaryView>> for BinaryView {
6015 type Value = ::planus::Offset<BinaryView>;
6016 const STRIDE: usize = 4;
6017 #[inline]
6018 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
6019 ::planus::WriteAs::prepare(self, builder)
6020 }
6021
6022 #[inline]
6023 unsafe fn write_values(
6024 values: &[::planus::Offset<BinaryView>],
6025 bytes: *mut ::core::mem::MaybeUninit<u8>,
6026 buffer_position: u32,
6027 ) {
6028 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
6029 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
6030 ::planus::WriteAsPrimitive::write(
6031 v,
6032 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
6033 buffer_position - (Self::STRIDE * i) as u32,
6034 );
6035 }
6036 }
6037 }
6038
6039 impl<'a> ::planus::ReadAsRoot<'a> for BinaryViewRef<'a> {
6040 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
6041 ::planus::TableRead::from_buffer(
6042 ::planus::SliceWithStartOffset {
6043 buffer: slice,
6044 offset_from_start: 0,
6045 },
6046 0,
6047 )
6048 .map_err(|error_kind| {
6049 error_kind.with_error_location("[BinaryViewRef]", "read_as_root", 0)
6050 })
6051 }
6052 }
6053
6054 /// The table `FixedSizeBinary` in the namespace `org.apache.arrow.flatbuf`
6055 ///
6056 /// Generated from these locations:
6057 /// * Table `FixedSizeBinary` in the file `Schema.fbs:209`
6058 #[derive(
6059 Clone,
6060 Debug,
6061 PartialEq,
6062 PartialOrd,
6063 Eq,
6064 Ord,
6065 Hash,
6066 ::serde::Serialize,
6067 ::serde::Deserialize,
6068 )]
6069 pub struct FixedSizeBinary {
6070 /// Number of bytes per value
6071 pub byte_width: i32,
6072 }
6073
6074 #[allow(clippy::derivable_impls)]
6075 impl ::core::default::Default for FixedSizeBinary {
6076 fn default() -> Self {
6077 Self { byte_width: 0 }
6078 }
6079 }
6080
6081 impl FixedSizeBinary {
6082 /// Creates a [FixedSizeBinaryBuilder] for serializing an instance of this table.
6083 #[inline]
6084 pub fn builder() -> FixedSizeBinaryBuilder<()> {
6085 FixedSizeBinaryBuilder(())
6086 }
6087
6088 #[allow(clippy::too_many_arguments)]
6089 pub fn create(
6090 builder: &mut ::planus::Builder,
6091 field_byte_width: impl ::planus::WriteAsDefault<i32, i32>,
6092 ) -> ::planus::Offset<Self> {
6093 let prepared_byte_width = field_byte_width.prepare(builder, &0);
6094
6095 let mut table_writer: ::planus::table_writer::TableWriter<6> =
6096 ::core::default::Default::default();
6097 if prepared_byte_width.is_some() {
6098 table_writer.write_entry::<i32>(0);
6099 }
6100
6101 unsafe {
6102 table_writer.finish(builder, |object_writer| {
6103 if let ::core::option::Option::Some(prepared_byte_width) =
6104 prepared_byte_width
6105 {
6106 object_writer.write::<_, _, 4>(&prepared_byte_width);
6107 }
6108 });
6109 }
6110 builder.current_offset()
6111 }
6112 }
6113
6114 impl ::planus::WriteAs<::planus::Offset<FixedSizeBinary>> for FixedSizeBinary {
6115 type Prepared = ::planus::Offset<Self>;
6116
6117 #[inline]
6118 fn prepare(
6119 &self,
6120 builder: &mut ::planus::Builder,
6121 ) -> ::planus::Offset<FixedSizeBinary> {
6122 ::planus::WriteAsOffset::prepare(self, builder)
6123 }
6124 }
6125
6126 impl ::planus::WriteAsOptional<::planus::Offset<FixedSizeBinary>> for FixedSizeBinary {
6127 type Prepared = ::planus::Offset<Self>;
6128
6129 #[inline]
6130 fn prepare(
6131 &self,
6132 builder: &mut ::planus::Builder,
6133 ) -> ::core::option::Option<::planus::Offset<FixedSizeBinary>>
6134 {
6135 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6136 self, builder,
6137 ))
6138 }
6139 }
6140
6141 impl ::planus::WriteAsOffset<FixedSizeBinary> for FixedSizeBinary {
6142 #[inline]
6143 fn prepare(
6144 &self,
6145 builder: &mut ::planus::Builder,
6146 ) -> ::planus::Offset<FixedSizeBinary> {
6147 FixedSizeBinary::create(builder, self.byte_width)
6148 }
6149 }
6150
6151 /// Builder for serializing an instance of the [FixedSizeBinary] type.
6152 ///
6153 /// Can be created using the [FixedSizeBinary::builder] method.
6154 #[derive(Debug)]
6155 #[must_use]
6156 pub struct FixedSizeBinaryBuilder<State>(State);
6157
6158 impl FixedSizeBinaryBuilder<()> {
6159 /// Setter for the [`byteWidth` field](FixedSizeBinary#structfield.byte_width).
6160 #[inline]
6161 #[allow(clippy::type_complexity)]
6162 pub fn byte_width<T0>(self, value: T0) -> FixedSizeBinaryBuilder<(T0,)>
6163 where
6164 T0: ::planus::WriteAsDefault<i32, i32>,
6165 {
6166 FixedSizeBinaryBuilder((value,))
6167 }
6168
6169 /// Sets the [`byteWidth` field](FixedSizeBinary#structfield.byte_width) to the default value.
6170 #[inline]
6171 #[allow(clippy::type_complexity)]
6172 pub fn byte_width_as_default(
6173 self,
6174 ) -> FixedSizeBinaryBuilder<(::planus::DefaultValue,)>
6175 {
6176 self.byte_width(::planus::DefaultValue)
6177 }
6178 }
6179
6180 impl<T0> FixedSizeBinaryBuilder<(T0,)> {
6181 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [FixedSizeBinary].
6182 #[inline]
6183 pub fn finish(
6184 self,
6185 builder: &mut ::planus::Builder,
6186 ) -> ::planus::Offset<FixedSizeBinary>
6187 where
6188 Self: ::planus::WriteAsOffset<FixedSizeBinary>,
6189 {
6190 ::planus::WriteAsOffset::prepare(&self, builder)
6191 }
6192 }
6193
6194 impl<T0: ::planus::WriteAsDefault<i32, i32>>
6195 ::planus::WriteAs<::planus::Offset<FixedSizeBinary>>
6196 for FixedSizeBinaryBuilder<(T0,)>
6197 {
6198 type Prepared = ::planus::Offset<FixedSizeBinary>;
6199
6200 #[inline]
6201 fn prepare(
6202 &self,
6203 builder: &mut ::planus::Builder,
6204 ) -> ::planus::Offset<FixedSizeBinary> {
6205 ::planus::WriteAsOffset::prepare(self, builder)
6206 }
6207 }
6208
6209 impl<T0: ::planus::WriteAsDefault<i32, i32>>
6210 ::planus::WriteAsOptional<::planus::Offset<FixedSizeBinary>>
6211 for FixedSizeBinaryBuilder<(T0,)>
6212 {
6213 type Prepared = ::planus::Offset<FixedSizeBinary>;
6214
6215 #[inline]
6216 fn prepare(
6217 &self,
6218 builder: &mut ::planus::Builder,
6219 ) -> ::core::option::Option<::planus::Offset<FixedSizeBinary>>
6220 {
6221 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6222 self, builder,
6223 ))
6224 }
6225 }
6226
6227 impl<T0: ::planus::WriteAsDefault<i32, i32>>
6228 ::planus::WriteAsOffset<FixedSizeBinary> for FixedSizeBinaryBuilder<(T0,)>
6229 {
6230 #[inline]
6231 fn prepare(
6232 &self,
6233 builder: &mut ::planus::Builder,
6234 ) -> ::planus::Offset<FixedSizeBinary> {
6235 let (v0,) = &self.0;
6236 FixedSizeBinary::create(builder, v0)
6237 }
6238 }
6239
6240 /// Reference to a deserialized [FixedSizeBinary].
6241 #[derive(Copy, Clone)]
6242 pub struct FixedSizeBinaryRef<'a>(::planus::table_reader::Table<'a>);
6243
6244 impl<'a> FixedSizeBinaryRef<'a> {
6245 /// Getter for the [`byteWidth` field](FixedSizeBinary#structfield.byte_width).
6246 #[inline]
6247 pub fn byte_width(&self) -> ::planus::Result<i32> {
6248 ::core::result::Result::Ok(
6249 self.0
6250 .access(0, "FixedSizeBinary", "byte_width")?
6251 .unwrap_or(0),
6252 )
6253 }
6254 }
6255
6256 impl<'a> ::core::fmt::Debug for FixedSizeBinaryRef<'a> {
6257 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
6258 let mut f = f.debug_struct("FixedSizeBinaryRef");
6259 f.field("byte_width", &self.byte_width());
6260 f.finish()
6261 }
6262 }
6263
6264 impl<'a> ::core::convert::TryFrom<FixedSizeBinaryRef<'a>> for FixedSizeBinary {
6265 type Error = ::planus::Error;
6266
6267 #[allow(unreachable_code)]
6268 fn try_from(value: FixedSizeBinaryRef<'a>) -> ::planus::Result<Self> {
6269 ::core::result::Result::Ok(Self {
6270 byte_width: ::core::convert::TryInto::try_into(
6271 value.byte_width()?,
6272 )?,
6273 })
6274 }
6275 }
6276
6277 impl<'a> ::planus::TableRead<'a> for FixedSizeBinaryRef<'a> {
6278 #[inline]
6279 fn from_buffer(
6280 buffer: ::planus::SliceWithStartOffset<'a>,
6281 offset: usize,
6282 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
6283 {
6284 ::core::result::Result::Ok(Self(
6285 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
6286 ))
6287 }
6288 }
6289
6290 impl<'a> ::planus::VectorReadInner<'a> for FixedSizeBinaryRef<'a> {
6291 type Error = ::planus::Error;
6292 const STRIDE: usize = 4;
6293
6294 unsafe fn from_buffer(
6295 buffer: ::planus::SliceWithStartOffset<'a>,
6296 offset: usize,
6297 ) -> ::planus::Result<Self> {
6298 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
6299 error_kind.with_error_location(
6300 "[FixedSizeBinaryRef]",
6301 "get",
6302 buffer.offset_from_start,
6303 )
6304 })
6305 }
6306 }
6307
6308 /// # Safety
6309 /// The planus compiler generates implementations that initialize
6310 /// the bytes in `write_values`.
6311 unsafe impl ::planus::VectorWrite<::planus::Offset<FixedSizeBinary>> for FixedSizeBinary {
6312 type Value = ::planus::Offset<FixedSizeBinary>;
6313 const STRIDE: usize = 4;
6314 #[inline]
6315 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
6316 ::planus::WriteAs::prepare(self, builder)
6317 }
6318
6319 #[inline]
6320 unsafe fn write_values(
6321 values: &[::planus::Offset<FixedSizeBinary>],
6322 bytes: *mut ::core::mem::MaybeUninit<u8>,
6323 buffer_position: u32,
6324 ) {
6325 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
6326 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
6327 ::planus::WriteAsPrimitive::write(
6328 v,
6329 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
6330 buffer_position - (Self::STRIDE * i) as u32,
6331 );
6332 }
6333 }
6334 }
6335
6336 impl<'a> ::planus::ReadAsRoot<'a> for FixedSizeBinaryRef<'a> {
6337 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
6338 ::planus::TableRead::from_buffer(
6339 ::planus::SliceWithStartOffset {
6340 buffer: slice,
6341 offset_from_start: 0,
6342 },
6343 0,
6344 )
6345 .map_err(|error_kind| {
6346 error_kind.with_error_location(
6347 "[FixedSizeBinaryRef]",
6348 "read_as_root",
6349 0,
6350 )
6351 })
6352 }
6353 }
6354
6355 /// The table `Bool` in the namespace `org.apache.arrow.flatbuf`
6356 ///
6357 /// Generated from these locations:
6358 /// * Table `Bool` in the file `Schema.fbs:214`
6359 #[derive(
6360 Clone,
6361 Debug,
6362 PartialEq,
6363 PartialOrd,
6364 Eq,
6365 Ord,
6366 Hash,
6367 ::serde::Serialize,
6368 ::serde::Deserialize,
6369 )]
6370 pub struct Bool {}
6371
6372 #[allow(clippy::derivable_impls)]
6373 impl ::core::default::Default for Bool {
6374 fn default() -> Self {
6375 Self {}
6376 }
6377 }
6378
6379 impl Bool {
6380 /// Creates a [BoolBuilder] for serializing an instance of this table.
6381 #[inline]
6382 pub fn builder() -> BoolBuilder<()> {
6383 BoolBuilder(())
6384 }
6385
6386 #[allow(clippy::too_many_arguments)]
6387 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
6388 let table_writer: ::planus::table_writer::TableWriter<4> =
6389 ::core::default::Default::default();
6390 unsafe {
6391 table_writer.finish(builder, |_table_writer| {});
6392 }
6393 builder.current_offset()
6394 }
6395 }
6396
6397 impl ::planus::WriteAs<::planus::Offset<Bool>> for Bool {
6398 type Prepared = ::planus::Offset<Self>;
6399
6400 #[inline]
6401 fn prepare(
6402 &self,
6403 builder: &mut ::planus::Builder,
6404 ) -> ::planus::Offset<Bool> {
6405 ::planus::WriteAsOffset::prepare(self, builder)
6406 }
6407 }
6408
6409 impl ::planus::WriteAsOptional<::planus::Offset<Bool>> for Bool {
6410 type Prepared = ::planus::Offset<Self>;
6411
6412 #[inline]
6413 fn prepare(
6414 &self,
6415 builder: &mut ::planus::Builder,
6416 ) -> ::core::option::Option<::planus::Offset<Bool>>
6417 {
6418 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6419 self, builder,
6420 ))
6421 }
6422 }
6423
6424 impl ::planus::WriteAsOffset<Bool> for Bool {
6425 #[inline]
6426 fn prepare(
6427 &self,
6428 builder: &mut ::planus::Builder,
6429 ) -> ::planus::Offset<Bool> {
6430 Bool::create(builder)
6431 }
6432 }
6433
6434 /// Builder for serializing an instance of the [Bool] type.
6435 ///
6436 /// Can be created using the [Bool::builder] method.
6437 #[derive(Debug)]
6438 #[must_use]
6439 pub struct BoolBuilder<State>(State);
6440
6441 impl BoolBuilder<()> {
6442 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Bool].
6443 #[inline]
6444 pub fn finish(
6445 self,
6446 builder: &mut ::planus::Builder,
6447 ) -> ::planus::Offset<Bool>
6448 where
6449 Self: ::planus::WriteAsOffset<Bool>,
6450 {
6451 ::planus::WriteAsOffset::prepare(&self, builder)
6452 }
6453 }
6454
6455 impl ::planus::WriteAs<::planus::Offset<Bool>> for BoolBuilder<()> {
6456 type Prepared = ::planus::Offset<Bool>;
6457
6458 #[inline]
6459 fn prepare(
6460 &self,
6461 builder: &mut ::planus::Builder,
6462 ) -> ::planus::Offset<Bool> {
6463 ::planus::WriteAsOffset::prepare(self, builder)
6464 }
6465 }
6466
6467 impl ::planus::WriteAsOptional<::planus::Offset<Bool>> for BoolBuilder<()> {
6468 type Prepared = ::planus::Offset<Bool>;
6469
6470 #[inline]
6471 fn prepare(
6472 &self,
6473 builder: &mut ::planus::Builder,
6474 ) -> ::core::option::Option<::planus::Offset<Bool>>
6475 {
6476 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6477 self, builder,
6478 ))
6479 }
6480 }
6481
6482 impl ::planus::WriteAsOffset<Bool> for BoolBuilder<()> {
6483 #[inline]
6484 fn prepare(
6485 &self,
6486 builder: &mut ::planus::Builder,
6487 ) -> ::planus::Offset<Bool> {
6488 Bool::create(builder)
6489 }
6490 }
6491
6492 /// Reference to a deserialized [Bool].
6493 #[derive(Copy, Clone)]
6494 pub struct BoolRef<'a>(::planus::table_reader::Table<'a>);
6495
6496 impl<'a> BoolRef<'a> {}
6497
6498 impl<'a> ::core::fmt::Debug for BoolRef<'a> {
6499 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
6500 let mut f = f.debug_struct("BoolRef");
6501
6502 f.finish()
6503 }
6504 }
6505
6506 impl<'a> ::core::convert::TryFrom<BoolRef<'a>> for Bool {
6507 type Error = ::planus::Error;
6508
6509 fn try_from(_value: BoolRef<'a>) -> ::planus::Result<Self> {
6510 ::core::result::Result::Ok(Self {})
6511 }
6512 }
6513
6514 impl<'a> ::planus::TableRead<'a> for BoolRef<'a> {
6515 #[inline]
6516 fn from_buffer(
6517 buffer: ::planus::SliceWithStartOffset<'a>,
6518 offset: usize,
6519 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
6520 {
6521 ::core::result::Result::Ok(Self(
6522 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
6523 ))
6524 }
6525 }
6526
6527 impl<'a> ::planus::VectorReadInner<'a> for BoolRef<'a> {
6528 type Error = ::planus::Error;
6529 const STRIDE: usize = 4;
6530
6531 unsafe fn from_buffer(
6532 buffer: ::planus::SliceWithStartOffset<'a>,
6533 offset: usize,
6534 ) -> ::planus::Result<Self> {
6535 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
6536 error_kind.with_error_location(
6537 "[BoolRef]",
6538 "get",
6539 buffer.offset_from_start,
6540 )
6541 })
6542 }
6543 }
6544
6545 /// # Safety
6546 /// The planus compiler generates implementations that initialize
6547 /// the bytes in `write_values`.
6548 unsafe impl ::planus::VectorWrite<::planus::Offset<Bool>> for Bool {
6549 type Value = ::planus::Offset<Bool>;
6550 const STRIDE: usize = 4;
6551 #[inline]
6552 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
6553 ::planus::WriteAs::prepare(self, builder)
6554 }
6555
6556 #[inline]
6557 unsafe fn write_values(
6558 values: &[::planus::Offset<Bool>],
6559 bytes: *mut ::core::mem::MaybeUninit<u8>,
6560 buffer_position: u32,
6561 ) {
6562 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
6563 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
6564 ::planus::WriteAsPrimitive::write(
6565 v,
6566 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
6567 buffer_position - (Self::STRIDE * i) as u32,
6568 );
6569 }
6570 }
6571 }
6572
6573 impl<'a> ::planus::ReadAsRoot<'a> for BoolRef<'a> {
6574 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
6575 ::planus::TableRead::from_buffer(
6576 ::planus::SliceWithStartOffset {
6577 buffer: slice,
6578 offset_from_start: 0,
6579 },
6580 0,
6581 )
6582 .map_err(|error_kind| {
6583 error_kind.with_error_location("[BoolRef]", "read_as_root", 0)
6584 })
6585 }
6586 }
6587
6588 /// Contains two child arrays, run_ends and values.
6589 /// The run_ends child array must be a 16/32/64-bit integer array
6590 /// which encodes the indices at which the run with the value in
6591 /// each corresponding index in the values child array ends.
6592 /// Like list/struct types, the value array can be of any type.
6593 ///
6594 /// Generated from these locations:
6595 /// * Table `RunEndEncoded` in the file `Schema.fbs:222`
6596 #[derive(
6597 Clone,
6598 Debug,
6599 PartialEq,
6600 PartialOrd,
6601 Eq,
6602 Ord,
6603 Hash,
6604 ::serde::Serialize,
6605 ::serde::Deserialize,
6606 )]
6607 pub struct RunEndEncoded {}
6608
6609 #[allow(clippy::derivable_impls)]
6610 impl ::core::default::Default for RunEndEncoded {
6611 fn default() -> Self {
6612 Self {}
6613 }
6614 }
6615
6616 impl RunEndEncoded {
6617 /// Creates a [RunEndEncodedBuilder] for serializing an instance of this table.
6618 #[inline]
6619 pub fn builder() -> RunEndEncodedBuilder<()> {
6620 RunEndEncodedBuilder(())
6621 }
6622
6623 #[allow(clippy::too_many_arguments)]
6624 pub fn create(builder: &mut ::planus::Builder) -> ::planus::Offset<Self> {
6625 let table_writer: ::planus::table_writer::TableWriter<4> =
6626 ::core::default::Default::default();
6627 unsafe {
6628 table_writer.finish(builder, |_table_writer| {});
6629 }
6630 builder.current_offset()
6631 }
6632 }
6633
6634 impl ::planus::WriteAs<::planus::Offset<RunEndEncoded>> for RunEndEncoded {
6635 type Prepared = ::planus::Offset<Self>;
6636
6637 #[inline]
6638 fn prepare(
6639 &self,
6640 builder: &mut ::planus::Builder,
6641 ) -> ::planus::Offset<RunEndEncoded> {
6642 ::planus::WriteAsOffset::prepare(self, builder)
6643 }
6644 }
6645
6646 impl ::planus::WriteAsOptional<::planus::Offset<RunEndEncoded>> for RunEndEncoded {
6647 type Prepared = ::planus::Offset<Self>;
6648
6649 #[inline]
6650 fn prepare(
6651 &self,
6652 builder: &mut ::planus::Builder,
6653 ) -> ::core::option::Option<::planus::Offset<RunEndEncoded>>
6654 {
6655 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6656 self, builder,
6657 ))
6658 }
6659 }
6660
6661 impl ::planus::WriteAsOffset<RunEndEncoded> for RunEndEncoded {
6662 #[inline]
6663 fn prepare(
6664 &self,
6665 builder: &mut ::planus::Builder,
6666 ) -> ::planus::Offset<RunEndEncoded> {
6667 RunEndEncoded::create(builder)
6668 }
6669 }
6670
6671 /// Builder for serializing an instance of the [RunEndEncoded] type.
6672 ///
6673 /// Can be created using the [RunEndEncoded::builder] method.
6674 #[derive(Debug)]
6675 #[must_use]
6676 pub struct RunEndEncodedBuilder<State>(State);
6677
6678 impl RunEndEncodedBuilder<()> {
6679 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RunEndEncoded].
6680 #[inline]
6681 pub fn finish(
6682 self,
6683 builder: &mut ::planus::Builder,
6684 ) -> ::planus::Offset<RunEndEncoded>
6685 where
6686 Self: ::planus::WriteAsOffset<RunEndEncoded>,
6687 {
6688 ::planus::WriteAsOffset::prepare(&self, builder)
6689 }
6690 }
6691
6692 impl ::planus::WriteAs<::planus::Offset<RunEndEncoded>> for RunEndEncodedBuilder<()> {
6693 type Prepared = ::planus::Offset<RunEndEncoded>;
6694
6695 #[inline]
6696 fn prepare(
6697 &self,
6698 builder: &mut ::planus::Builder,
6699 ) -> ::planus::Offset<RunEndEncoded> {
6700 ::planus::WriteAsOffset::prepare(self, builder)
6701 }
6702 }
6703
6704 impl ::planus::WriteAsOptional<::planus::Offset<RunEndEncoded>> for RunEndEncodedBuilder<()> {
6705 type Prepared = ::planus::Offset<RunEndEncoded>;
6706
6707 #[inline]
6708 fn prepare(
6709 &self,
6710 builder: &mut ::planus::Builder,
6711 ) -> ::core::option::Option<::planus::Offset<RunEndEncoded>>
6712 {
6713 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6714 self, builder,
6715 ))
6716 }
6717 }
6718
6719 impl ::planus::WriteAsOffset<RunEndEncoded> for RunEndEncodedBuilder<()> {
6720 #[inline]
6721 fn prepare(
6722 &self,
6723 builder: &mut ::planus::Builder,
6724 ) -> ::planus::Offset<RunEndEncoded> {
6725 RunEndEncoded::create(builder)
6726 }
6727 }
6728
6729 /// Reference to a deserialized [RunEndEncoded].
6730 #[derive(Copy, Clone)]
6731 pub struct RunEndEncodedRef<'a>(::planus::table_reader::Table<'a>);
6732
6733 impl<'a> RunEndEncodedRef<'a> {}
6734
6735 impl<'a> ::core::fmt::Debug for RunEndEncodedRef<'a> {
6736 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
6737 let mut f = f.debug_struct("RunEndEncodedRef");
6738
6739 f.finish()
6740 }
6741 }
6742
6743 impl<'a> ::core::convert::TryFrom<RunEndEncodedRef<'a>> for RunEndEncoded {
6744 type Error = ::planus::Error;
6745
6746 fn try_from(_value: RunEndEncodedRef<'a>) -> ::planus::Result<Self> {
6747 ::core::result::Result::Ok(Self {})
6748 }
6749 }
6750
6751 impl<'a> ::planus::TableRead<'a> for RunEndEncodedRef<'a> {
6752 #[inline]
6753 fn from_buffer(
6754 buffer: ::planus::SliceWithStartOffset<'a>,
6755 offset: usize,
6756 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
6757 {
6758 ::core::result::Result::Ok(Self(
6759 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
6760 ))
6761 }
6762 }
6763
6764 impl<'a> ::planus::VectorReadInner<'a> for RunEndEncodedRef<'a> {
6765 type Error = ::planus::Error;
6766 const STRIDE: usize = 4;
6767
6768 unsafe fn from_buffer(
6769 buffer: ::planus::SliceWithStartOffset<'a>,
6770 offset: usize,
6771 ) -> ::planus::Result<Self> {
6772 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
6773 error_kind.with_error_location(
6774 "[RunEndEncodedRef]",
6775 "get",
6776 buffer.offset_from_start,
6777 )
6778 })
6779 }
6780 }
6781
6782 /// # Safety
6783 /// The planus compiler generates implementations that initialize
6784 /// the bytes in `write_values`.
6785 unsafe impl ::planus::VectorWrite<::planus::Offset<RunEndEncoded>> for RunEndEncoded {
6786 type Value = ::planus::Offset<RunEndEncoded>;
6787 const STRIDE: usize = 4;
6788 #[inline]
6789 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
6790 ::planus::WriteAs::prepare(self, builder)
6791 }
6792
6793 #[inline]
6794 unsafe fn write_values(
6795 values: &[::planus::Offset<RunEndEncoded>],
6796 bytes: *mut ::core::mem::MaybeUninit<u8>,
6797 buffer_position: u32,
6798 ) {
6799 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
6800 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
6801 ::planus::WriteAsPrimitive::write(
6802 v,
6803 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
6804 buffer_position - (Self::STRIDE * i) as u32,
6805 );
6806 }
6807 }
6808 }
6809
6810 impl<'a> ::planus::ReadAsRoot<'a> for RunEndEncodedRef<'a> {
6811 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
6812 ::planus::TableRead::from_buffer(
6813 ::planus::SliceWithStartOffset {
6814 buffer: slice,
6815 offset_from_start: 0,
6816 },
6817 0,
6818 )
6819 .map_err(|error_kind| {
6820 error_kind.with_error_location(
6821 "[RunEndEncodedRef]",
6822 "read_as_root",
6823 0,
6824 )
6825 })
6826 }
6827 }
6828
6829 /// Exact decimal value represented as an integer value in two's
6830 /// complement. Currently 32-bit (4-byte), 64-bit (8-byte),
6831 /// 128-bit (16-byte) and 256-bit (32-byte) integers are used.
6832 /// The representation uses the endianness indicated in the Schema.
6833 ///
6834 /// Generated from these locations:
6835 /// * Table `Decimal` in the file `Schema.fbs:229`
6836 #[derive(
6837 Clone,
6838 Debug,
6839 PartialEq,
6840 PartialOrd,
6841 Eq,
6842 Ord,
6843 Hash,
6844 ::serde::Serialize,
6845 ::serde::Deserialize,
6846 )]
6847 pub struct Decimal {
6848 /// Total number of decimal digits
6849 pub precision: i32,
6850 /// Number of digits after the decimal point "."
6851 pub scale: i32,
6852 /// Number of bits per value. The accepted widths are 32, 64, 128 and 256.
6853 /// We use bitWidth for consistency with Int::bitWidth.
6854 pub bit_width: i32,
6855 }
6856
6857 #[allow(clippy::derivable_impls)]
6858 impl ::core::default::Default for Decimal {
6859 fn default() -> Self {
6860 Self {
6861 precision: 0,
6862 scale: 0,
6863 bit_width: 128,
6864 }
6865 }
6866 }
6867
6868 impl Decimal {
6869 /// Creates a [DecimalBuilder] for serializing an instance of this table.
6870 #[inline]
6871 pub fn builder() -> DecimalBuilder<()> {
6872 DecimalBuilder(())
6873 }
6874
6875 #[allow(clippy::too_many_arguments)]
6876 pub fn create(
6877 builder: &mut ::planus::Builder,
6878 field_precision: impl ::planus::WriteAsDefault<i32, i32>,
6879 field_scale: impl ::planus::WriteAsDefault<i32, i32>,
6880 field_bit_width: impl ::planus::WriteAsDefault<i32, i32>,
6881 ) -> ::planus::Offset<Self> {
6882 let prepared_precision = field_precision.prepare(builder, &0);
6883 let prepared_scale = field_scale.prepare(builder, &0);
6884 let prepared_bit_width = field_bit_width.prepare(builder, &128);
6885
6886 let mut table_writer: ::planus::table_writer::TableWriter<10> =
6887 ::core::default::Default::default();
6888 if prepared_precision.is_some() {
6889 table_writer.write_entry::<i32>(0);
6890 }
6891 if prepared_scale.is_some() {
6892 table_writer.write_entry::<i32>(1);
6893 }
6894 if prepared_bit_width.is_some() {
6895 table_writer.write_entry::<i32>(2);
6896 }
6897
6898 unsafe {
6899 table_writer.finish(builder, |object_writer| {
6900 if let ::core::option::Option::Some(prepared_precision) =
6901 prepared_precision
6902 {
6903 object_writer.write::<_, _, 4>(&prepared_precision);
6904 }
6905 if let ::core::option::Option::Some(prepared_scale) =
6906 prepared_scale
6907 {
6908 object_writer.write::<_, _, 4>(&prepared_scale);
6909 }
6910 if let ::core::option::Option::Some(prepared_bit_width) =
6911 prepared_bit_width
6912 {
6913 object_writer.write::<_, _, 4>(&prepared_bit_width);
6914 }
6915 });
6916 }
6917 builder.current_offset()
6918 }
6919 }
6920
6921 impl ::planus::WriteAs<::planus::Offset<Decimal>> for Decimal {
6922 type Prepared = ::planus::Offset<Self>;
6923
6924 #[inline]
6925 fn prepare(
6926 &self,
6927 builder: &mut ::planus::Builder,
6928 ) -> ::planus::Offset<Decimal> {
6929 ::planus::WriteAsOffset::prepare(self, builder)
6930 }
6931 }
6932
6933 impl ::planus::WriteAsOptional<::planus::Offset<Decimal>> for Decimal {
6934 type Prepared = ::planus::Offset<Self>;
6935
6936 #[inline]
6937 fn prepare(
6938 &self,
6939 builder: &mut ::planus::Builder,
6940 ) -> ::core::option::Option<::planus::Offset<Decimal>>
6941 {
6942 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
6943 self, builder,
6944 ))
6945 }
6946 }
6947
6948 impl ::planus::WriteAsOffset<Decimal> for Decimal {
6949 #[inline]
6950 fn prepare(
6951 &self,
6952 builder: &mut ::planus::Builder,
6953 ) -> ::planus::Offset<Decimal> {
6954 Decimal::create(builder, self.precision, self.scale, self.bit_width)
6955 }
6956 }
6957
6958 /// Builder for serializing an instance of the [Decimal] type.
6959 ///
6960 /// Can be created using the [Decimal::builder] method.
6961 #[derive(Debug)]
6962 #[must_use]
6963 pub struct DecimalBuilder<State>(State);
6964
6965 impl DecimalBuilder<()> {
6966 /// Setter for the [`precision` field](Decimal#structfield.precision).
6967 #[inline]
6968 #[allow(clippy::type_complexity)]
6969 pub fn precision<T0>(self, value: T0) -> DecimalBuilder<(T0,)>
6970 where
6971 T0: ::planus::WriteAsDefault<i32, i32>,
6972 {
6973 DecimalBuilder((value,))
6974 }
6975
6976 /// Sets the [`precision` field](Decimal#structfield.precision) to the default value.
6977 #[inline]
6978 #[allow(clippy::type_complexity)]
6979 pub fn precision_as_default(
6980 self,
6981 ) -> DecimalBuilder<(::planus::DefaultValue,)> {
6982 self.precision(::planus::DefaultValue)
6983 }
6984 }
6985
6986 impl<T0> DecimalBuilder<(T0,)> {
6987 /// Setter for the [`scale` field](Decimal#structfield.scale).
6988 #[inline]
6989 #[allow(clippy::type_complexity)]
6990 pub fn scale<T1>(self, value: T1) -> DecimalBuilder<(T0, T1)>
6991 where
6992 T1: ::planus::WriteAsDefault<i32, i32>,
6993 {
6994 let (v0,) = self.0;
6995 DecimalBuilder((v0, value))
6996 }
6997
6998 /// Sets the [`scale` field](Decimal#structfield.scale) to the default value.
6999 #[inline]
7000 #[allow(clippy::type_complexity)]
7001 pub fn scale_as_default(
7002 self,
7003 ) -> DecimalBuilder<(T0, ::planus::DefaultValue)> {
7004 self.scale(::planus::DefaultValue)
7005 }
7006 }
7007
7008 impl<T0, T1> DecimalBuilder<(T0, T1)> {
7009 /// Setter for the [`bitWidth` field](Decimal#structfield.bit_width).
7010 #[inline]
7011 #[allow(clippy::type_complexity)]
7012 pub fn bit_width<T2>(self, value: T2) -> DecimalBuilder<(T0, T1, T2)>
7013 where
7014 T2: ::planus::WriteAsDefault<i32, i32>,
7015 {
7016 let (v0, v1) = self.0;
7017 DecimalBuilder((v0, v1, value))
7018 }
7019
7020 /// Sets the [`bitWidth` field](Decimal#structfield.bit_width) to the default value.
7021 #[inline]
7022 #[allow(clippy::type_complexity)]
7023 pub fn bit_width_as_default(
7024 self,
7025 ) -> DecimalBuilder<(T0, T1, ::planus::DefaultValue)>
7026 {
7027 self.bit_width(::planus::DefaultValue)
7028 }
7029 }
7030
7031 impl<T0, T1, T2> DecimalBuilder<(T0, T1, T2)> {
7032 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Decimal].
7033 #[inline]
7034 pub fn finish(
7035 self,
7036 builder: &mut ::planus::Builder,
7037 ) -> ::planus::Offset<Decimal>
7038 where
7039 Self: ::planus::WriteAsOffset<Decimal>,
7040 {
7041 ::planus::WriteAsOffset::prepare(&self, builder)
7042 }
7043 }
7044
7045 impl<
7046 T0: ::planus::WriteAsDefault<i32, i32>,
7047 T1: ::planus::WriteAsDefault<i32, i32>,
7048 T2: ::planus::WriteAsDefault<i32, i32>,
7049 > ::planus::WriteAs<::planus::Offset<Decimal>>
7050 for DecimalBuilder<(T0, T1, T2)>
7051 {
7052 type Prepared = ::planus::Offset<Decimal>;
7053
7054 #[inline]
7055 fn prepare(
7056 &self,
7057 builder: &mut ::planus::Builder,
7058 ) -> ::planus::Offset<Decimal> {
7059 ::planus::WriteAsOffset::prepare(self, builder)
7060 }
7061 }
7062
7063 impl<
7064 T0: ::planus::WriteAsDefault<i32, i32>,
7065 T1: ::planus::WriteAsDefault<i32, i32>,
7066 T2: ::planus::WriteAsDefault<i32, i32>,
7067 > ::planus::WriteAsOptional<::planus::Offset<Decimal>>
7068 for DecimalBuilder<(T0, T1, T2)>
7069 {
7070 type Prepared = ::planus::Offset<Decimal>;
7071
7072 #[inline]
7073 fn prepare(
7074 &self,
7075 builder: &mut ::planus::Builder,
7076 ) -> ::core::option::Option<::planus::Offset<Decimal>>
7077 {
7078 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
7079 self, builder,
7080 ))
7081 }
7082 }
7083
7084 impl<
7085 T0: ::planus::WriteAsDefault<i32, i32>,
7086 T1: ::planus::WriteAsDefault<i32, i32>,
7087 T2: ::planus::WriteAsDefault<i32, i32>,
7088 > ::planus::WriteAsOffset<Decimal> for DecimalBuilder<(T0, T1, T2)>
7089 {
7090 #[inline]
7091 fn prepare(
7092 &self,
7093 builder: &mut ::planus::Builder,
7094 ) -> ::planus::Offset<Decimal> {
7095 let (v0, v1, v2) = &self.0;
7096 Decimal::create(builder, v0, v1, v2)
7097 }
7098 }
7099
7100 /// Reference to a deserialized [Decimal].
7101 #[derive(Copy, Clone)]
7102 pub struct DecimalRef<'a>(::planus::table_reader::Table<'a>);
7103
7104 impl<'a> DecimalRef<'a> {
7105 /// Getter for the [`precision` field](Decimal#structfield.precision).
7106 #[inline]
7107 pub fn precision(&self) -> ::planus::Result<i32> {
7108 ::core::result::Result::Ok(
7109 self.0.access(0, "Decimal", "precision")?.unwrap_or(0),
7110 )
7111 }
7112
7113 /// Getter for the [`scale` field](Decimal#structfield.scale).
7114 #[inline]
7115 pub fn scale(&self) -> ::planus::Result<i32> {
7116 ::core::result::Result::Ok(
7117 self.0.access(1, "Decimal", "scale")?.unwrap_or(0),
7118 )
7119 }
7120
7121 /// Getter for the [`bitWidth` field](Decimal#structfield.bit_width).
7122 #[inline]
7123 pub fn bit_width(&self) -> ::planus::Result<i32> {
7124 ::core::result::Result::Ok(
7125 self.0.access(2, "Decimal", "bit_width")?.unwrap_or(128),
7126 )
7127 }
7128 }
7129
7130 impl<'a> ::core::fmt::Debug for DecimalRef<'a> {
7131 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
7132 let mut f = f.debug_struct("DecimalRef");
7133 f.field("precision", &self.precision());
7134 f.field("scale", &self.scale());
7135 f.field("bit_width", &self.bit_width());
7136 f.finish()
7137 }
7138 }
7139
7140 impl<'a> ::core::convert::TryFrom<DecimalRef<'a>> for Decimal {
7141 type Error = ::planus::Error;
7142
7143 #[allow(unreachable_code)]
7144 fn try_from(value: DecimalRef<'a>) -> ::planus::Result<Self> {
7145 ::core::result::Result::Ok(Self {
7146 precision: ::core::convert::TryInto::try_into(value.precision()?)?,
7147 scale: ::core::convert::TryInto::try_into(value.scale()?)?,
7148 bit_width: ::core::convert::TryInto::try_into(value.bit_width()?)?,
7149 })
7150 }
7151 }
7152
7153 impl<'a> ::planus::TableRead<'a> for DecimalRef<'a> {
7154 #[inline]
7155 fn from_buffer(
7156 buffer: ::planus::SliceWithStartOffset<'a>,
7157 offset: usize,
7158 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
7159 {
7160 ::core::result::Result::Ok(Self(
7161 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
7162 ))
7163 }
7164 }
7165
7166 impl<'a> ::planus::VectorReadInner<'a> for DecimalRef<'a> {
7167 type Error = ::planus::Error;
7168 const STRIDE: usize = 4;
7169
7170 unsafe fn from_buffer(
7171 buffer: ::planus::SliceWithStartOffset<'a>,
7172 offset: usize,
7173 ) -> ::planus::Result<Self> {
7174 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
7175 error_kind.with_error_location(
7176 "[DecimalRef]",
7177 "get",
7178 buffer.offset_from_start,
7179 )
7180 })
7181 }
7182 }
7183
7184 /// # Safety
7185 /// The planus compiler generates implementations that initialize
7186 /// the bytes in `write_values`.
7187 unsafe impl ::planus::VectorWrite<::planus::Offset<Decimal>> for Decimal {
7188 type Value = ::planus::Offset<Decimal>;
7189 const STRIDE: usize = 4;
7190 #[inline]
7191 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
7192 ::planus::WriteAs::prepare(self, builder)
7193 }
7194
7195 #[inline]
7196 unsafe fn write_values(
7197 values: &[::planus::Offset<Decimal>],
7198 bytes: *mut ::core::mem::MaybeUninit<u8>,
7199 buffer_position: u32,
7200 ) {
7201 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
7202 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
7203 ::planus::WriteAsPrimitive::write(
7204 v,
7205 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
7206 buffer_position - (Self::STRIDE * i) as u32,
7207 );
7208 }
7209 }
7210 }
7211
7212 impl<'a> ::planus::ReadAsRoot<'a> for DecimalRef<'a> {
7213 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
7214 ::planus::TableRead::from_buffer(
7215 ::planus::SliceWithStartOffset {
7216 buffer: slice,
7217 offset_from_start: 0,
7218 },
7219 0,
7220 )
7221 .map_err(|error_kind| {
7222 error_kind.with_error_location("[DecimalRef]", "read_as_root", 0)
7223 })
7224 }
7225 }
7226
7227 /// The enum `DateUnit` in the namespace `org.apache.arrow.flatbuf`
7228 ///
7229 /// Generated from these locations:
7230 /// * Enum `DateUnit` in the file `Schema.fbs:241`
7231 #[derive(
7232 Copy,
7233 Clone,
7234 Debug,
7235 PartialEq,
7236 Eq,
7237 PartialOrd,
7238 Ord,
7239 Hash,
7240 ::serde::Serialize,
7241 ::serde::Deserialize,
7242 )]
7243 #[repr(i16)]
7244 pub enum DateUnit {
7245 /// The variant `DAY` in the enum `DateUnit`
7246 Day = 0,
7247
7248 /// The variant `MILLISECOND` in the enum `DateUnit`
7249 Millisecond = 1,
7250 }
7251
7252 impl DateUnit {
7253 /// Array containing all valid variants of DateUnit
7254 pub const ENUM_VALUES: [Self; 2] = [Self::Day, Self::Millisecond];
7255 }
7256
7257 impl ::core::convert::TryFrom<i16> for DateUnit {
7258 type Error = ::planus::errors::UnknownEnumTagKind;
7259 #[inline]
7260 fn try_from(
7261 value: i16,
7262 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
7263 {
7264 #[allow(clippy::match_single_binding)]
7265 match value {
7266 0 => ::core::result::Result::Ok(DateUnit::Day),
7267 1 => ::core::result::Result::Ok(DateUnit::Millisecond),
7268
7269 _ => ::core::result::Result::Err(
7270 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
7271 ),
7272 }
7273 }
7274 }
7275
7276 impl ::core::convert::From<DateUnit> for i16 {
7277 #[inline]
7278 fn from(value: DateUnit) -> Self {
7279 value as i16
7280 }
7281 }
7282
7283 /// # Safety
7284 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
7285 unsafe impl ::planus::Primitive for DateUnit {
7286 const ALIGNMENT: usize = 2;
7287 const SIZE: usize = 2;
7288 }
7289
7290 impl ::planus::WriteAsPrimitive<DateUnit> for DateUnit {
7291 #[inline]
7292 fn write<const N: usize>(
7293 &self,
7294 cursor: ::planus::Cursor<'_, N>,
7295 buffer_position: u32,
7296 ) {
7297 (*self as i16).write(cursor, buffer_position);
7298 }
7299 }
7300
7301 impl ::planus::WriteAs<DateUnit> for DateUnit {
7302 type Prepared = Self;
7303
7304 #[inline]
7305 fn prepare(&self, _builder: &mut ::planus::Builder) -> DateUnit {
7306 *self
7307 }
7308 }
7309
7310 impl ::planus::WriteAsDefault<DateUnit, DateUnit> for DateUnit {
7311 type Prepared = Self;
7312
7313 #[inline]
7314 fn prepare(
7315 &self,
7316 _builder: &mut ::planus::Builder,
7317 default: &DateUnit,
7318 ) -> ::core::option::Option<DateUnit> {
7319 if self == default {
7320 ::core::option::Option::None
7321 } else {
7322 ::core::option::Option::Some(*self)
7323 }
7324 }
7325 }
7326
7327 impl ::planus::WriteAsOptional<DateUnit> for DateUnit {
7328 type Prepared = Self;
7329
7330 #[inline]
7331 fn prepare(
7332 &self,
7333 _builder: &mut ::planus::Builder,
7334 ) -> ::core::option::Option<DateUnit> {
7335 ::core::option::Option::Some(*self)
7336 }
7337 }
7338
7339 impl<'buf> ::planus::TableRead<'buf> for DateUnit {
7340 #[inline]
7341 fn from_buffer(
7342 buffer: ::planus::SliceWithStartOffset<'buf>,
7343 offset: usize,
7344 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
7345 {
7346 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
7347 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
7348 }
7349 }
7350
7351 impl<'buf> ::planus::VectorReadInner<'buf> for DateUnit {
7352 type Error = ::planus::errors::UnknownEnumTag;
7353 const STRIDE: usize = 2;
7354 #[inline]
7355 unsafe fn from_buffer(
7356 buffer: ::planus::SliceWithStartOffset<'buf>,
7357 offset: usize,
7358 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
7359 {
7360 let value = unsafe {
7361 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
7362 };
7363 let value: ::core::result::Result<Self, _> =
7364 ::core::convert::TryInto::try_into(value);
7365 value.map_err(|error_kind| {
7366 error_kind.with_error_location(
7367 "DateUnit",
7368 "VectorRead::from_buffer",
7369 buffer.offset_from_start,
7370 )
7371 })
7372 }
7373 }
7374
7375 /// # Safety
7376 /// The planus compiler generates implementations that initialize
7377 /// the bytes in `write_values`.
7378 unsafe impl ::planus::VectorWrite<DateUnit> for DateUnit {
7379 const STRIDE: usize = 2;
7380
7381 type Value = Self;
7382
7383 #[inline]
7384 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
7385 *self
7386 }
7387
7388 #[inline]
7389 unsafe fn write_values(
7390 values: &[Self],
7391 bytes: *mut ::core::mem::MaybeUninit<u8>,
7392 buffer_position: u32,
7393 ) {
7394 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
7395 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
7396 ::planus::WriteAsPrimitive::write(
7397 v,
7398 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
7399 buffer_position - (2 * i) as u32,
7400 );
7401 }
7402 }
7403 }
7404
7405 /// Date is either a 32-bit or 64-bit signed integer type representing an
7406 /// elapsed time since UNIX epoch (1970-01-01), stored in either of two units:
7407 ///
7408 /// * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no
7409 /// leap seconds), where the values are evenly divisible by 86400000
7410 /// * Days (32 bits) since the UNIX epoch
7411 ///
7412 /// Generated from these locations:
7413 /// * Table `Date` in the file `Schema.fbs:252`
7414 #[derive(
7415 Clone,
7416 Debug,
7417 PartialEq,
7418 PartialOrd,
7419 Eq,
7420 Ord,
7421 Hash,
7422 ::serde::Serialize,
7423 ::serde::Deserialize,
7424 )]
7425 pub struct Date {
7426 /// The field `unit` in the table `Date`
7427 pub unit: self::DateUnit,
7428 }
7429
7430 #[allow(clippy::derivable_impls)]
7431 impl ::core::default::Default for Date {
7432 fn default() -> Self {
7433 Self {
7434 unit: self::DateUnit::Millisecond,
7435 }
7436 }
7437 }
7438
7439 impl Date {
7440 /// Creates a [DateBuilder] for serializing an instance of this table.
7441 #[inline]
7442 pub fn builder() -> DateBuilder<()> {
7443 DateBuilder(())
7444 }
7445
7446 #[allow(clippy::too_many_arguments)]
7447 pub fn create(
7448 builder: &mut ::planus::Builder,
7449 field_unit: impl ::planus::WriteAsDefault<self::DateUnit, self::DateUnit>,
7450 ) -> ::planus::Offset<Self> {
7451 let prepared_unit =
7452 field_unit.prepare(builder, &self::DateUnit::Millisecond);
7453
7454 let mut table_writer: ::planus::table_writer::TableWriter<6> =
7455 ::core::default::Default::default();
7456 if prepared_unit.is_some() {
7457 table_writer.write_entry::<self::DateUnit>(0);
7458 }
7459
7460 unsafe {
7461 table_writer.finish(builder, |object_writer| {
7462 if let ::core::option::Option::Some(prepared_unit) =
7463 prepared_unit
7464 {
7465 object_writer.write::<_, _, 2>(&prepared_unit);
7466 }
7467 });
7468 }
7469 builder.current_offset()
7470 }
7471 }
7472
7473 impl ::planus::WriteAs<::planus::Offset<Date>> for Date {
7474 type Prepared = ::planus::Offset<Self>;
7475
7476 #[inline]
7477 fn prepare(
7478 &self,
7479 builder: &mut ::planus::Builder,
7480 ) -> ::planus::Offset<Date> {
7481 ::planus::WriteAsOffset::prepare(self, builder)
7482 }
7483 }
7484
7485 impl ::planus::WriteAsOptional<::planus::Offset<Date>> for Date {
7486 type Prepared = ::planus::Offset<Self>;
7487
7488 #[inline]
7489 fn prepare(
7490 &self,
7491 builder: &mut ::planus::Builder,
7492 ) -> ::core::option::Option<::planus::Offset<Date>>
7493 {
7494 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
7495 self, builder,
7496 ))
7497 }
7498 }
7499
7500 impl ::planus::WriteAsOffset<Date> for Date {
7501 #[inline]
7502 fn prepare(
7503 &self,
7504 builder: &mut ::planus::Builder,
7505 ) -> ::planus::Offset<Date> {
7506 Date::create(builder, self.unit)
7507 }
7508 }
7509
7510 /// Builder for serializing an instance of the [Date] type.
7511 ///
7512 /// Can be created using the [Date::builder] method.
7513 #[derive(Debug)]
7514 #[must_use]
7515 pub struct DateBuilder<State>(State);
7516
7517 impl DateBuilder<()> {
7518 /// Setter for the [`unit` field](Date#structfield.unit).
7519 #[inline]
7520 #[allow(clippy::type_complexity)]
7521 pub fn unit<T0>(self, value: T0) -> DateBuilder<(T0,)>
7522 where
7523 T0: ::planus::WriteAsDefault<self::DateUnit, self::DateUnit>,
7524 {
7525 DateBuilder((value,))
7526 }
7527
7528 /// Sets the [`unit` field](Date#structfield.unit) to the default value.
7529 #[inline]
7530 #[allow(clippy::type_complexity)]
7531 pub fn unit_as_default(self) -> DateBuilder<(::planus::DefaultValue,)> {
7532 self.unit(::planus::DefaultValue)
7533 }
7534 }
7535
7536 impl<T0> DateBuilder<(T0,)> {
7537 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Date].
7538 #[inline]
7539 pub fn finish(
7540 self,
7541 builder: &mut ::planus::Builder,
7542 ) -> ::planus::Offset<Date>
7543 where
7544 Self: ::planus::WriteAsOffset<Date>,
7545 {
7546 ::planus::WriteAsOffset::prepare(&self, builder)
7547 }
7548 }
7549
7550 impl<T0: ::planus::WriteAsDefault<self::DateUnit, self::DateUnit>>
7551 ::planus::WriteAs<::planus::Offset<Date>> for DateBuilder<(T0,)>
7552 {
7553 type Prepared = ::planus::Offset<Date>;
7554
7555 #[inline]
7556 fn prepare(
7557 &self,
7558 builder: &mut ::planus::Builder,
7559 ) -> ::planus::Offset<Date> {
7560 ::planus::WriteAsOffset::prepare(self, builder)
7561 }
7562 }
7563
7564 impl<T0: ::planus::WriteAsDefault<self::DateUnit, self::DateUnit>>
7565 ::planus::WriteAsOptional<::planus::Offset<Date>> for DateBuilder<(T0,)>
7566 {
7567 type Prepared = ::planus::Offset<Date>;
7568
7569 #[inline]
7570 fn prepare(
7571 &self,
7572 builder: &mut ::planus::Builder,
7573 ) -> ::core::option::Option<::planus::Offset<Date>>
7574 {
7575 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
7576 self, builder,
7577 ))
7578 }
7579 }
7580
7581 impl<T0: ::planus::WriteAsDefault<self::DateUnit, self::DateUnit>>
7582 ::planus::WriteAsOffset<Date> for DateBuilder<(T0,)>
7583 {
7584 #[inline]
7585 fn prepare(
7586 &self,
7587 builder: &mut ::planus::Builder,
7588 ) -> ::planus::Offset<Date> {
7589 let (v0,) = &self.0;
7590 Date::create(builder, v0)
7591 }
7592 }
7593
7594 /// Reference to a deserialized [Date].
7595 #[derive(Copy, Clone)]
7596 pub struct DateRef<'a>(::planus::table_reader::Table<'a>);
7597
7598 impl<'a> DateRef<'a> {
7599 /// Getter for the [`unit` field](Date#structfield.unit).
7600 #[inline]
7601 pub fn unit(&self) -> ::planus::Result<self::DateUnit> {
7602 ::core::result::Result::Ok(
7603 self.0
7604 .access(0, "Date", "unit")?
7605 .unwrap_or(self::DateUnit::Millisecond),
7606 )
7607 }
7608 }
7609
7610 impl<'a> ::core::fmt::Debug for DateRef<'a> {
7611 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
7612 let mut f = f.debug_struct("DateRef");
7613 f.field("unit", &self.unit());
7614 f.finish()
7615 }
7616 }
7617
7618 impl<'a> ::core::convert::TryFrom<DateRef<'a>> for Date {
7619 type Error = ::planus::Error;
7620
7621 #[allow(unreachable_code)]
7622 fn try_from(value: DateRef<'a>) -> ::planus::Result<Self> {
7623 ::core::result::Result::Ok(Self {
7624 unit: ::core::convert::TryInto::try_into(value.unit()?)?,
7625 })
7626 }
7627 }
7628
7629 impl<'a> ::planus::TableRead<'a> for DateRef<'a> {
7630 #[inline]
7631 fn from_buffer(
7632 buffer: ::planus::SliceWithStartOffset<'a>,
7633 offset: usize,
7634 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
7635 {
7636 ::core::result::Result::Ok(Self(
7637 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
7638 ))
7639 }
7640 }
7641
7642 impl<'a> ::planus::VectorReadInner<'a> for DateRef<'a> {
7643 type Error = ::planus::Error;
7644 const STRIDE: usize = 4;
7645
7646 unsafe fn from_buffer(
7647 buffer: ::planus::SliceWithStartOffset<'a>,
7648 offset: usize,
7649 ) -> ::planus::Result<Self> {
7650 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
7651 error_kind.with_error_location(
7652 "[DateRef]",
7653 "get",
7654 buffer.offset_from_start,
7655 )
7656 })
7657 }
7658 }
7659
7660 /// # Safety
7661 /// The planus compiler generates implementations that initialize
7662 /// the bytes in `write_values`.
7663 unsafe impl ::planus::VectorWrite<::planus::Offset<Date>> for Date {
7664 type Value = ::planus::Offset<Date>;
7665 const STRIDE: usize = 4;
7666 #[inline]
7667 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
7668 ::planus::WriteAs::prepare(self, builder)
7669 }
7670
7671 #[inline]
7672 unsafe fn write_values(
7673 values: &[::planus::Offset<Date>],
7674 bytes: *mut ::core::mem::MaybeUninit<u8>,
7675 buffer_position: u32,
7676 ) {
7677 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
7678 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
7679 ::planus::WriteAsPrimitive::write(
7680 v,
7681 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
7682 buffer_position - (Self::STRIDE * i) as u32,
7683 );
7684 }
7685 }
7686 }
7687
7688 impl<'a> ::planus::ReadAsRoot<'a> for DateRef<'a> {
7689 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
7690 ::planus::TableRead::from_buffer(
7691 ::planus::SliceWithStartOffset {
7692 buffer: slice,
7693 offset_from_start: 0,
7694 },
7695 0,
7696 )
7697 .map_err(|error_kind| {
7698 error_kind.with_error_location("[DateRef]", "read_as_root", 0)
7699 })
7700 }
7701 }
7702
7703 /// The enum `TimeUnit` in the namespace `org.apache.arrow.flatbuf`
7704 ///
7705 /// Generated from these locations:
7706 /// * Enum `TimeUnit` in the file `Schema.fbs:256`
7707 #[derive(
7708 Copy,
7709 Clone,
7710 Debug,
7711 PartialEq,
7712 Eq,
7713 PartialOrd,
7714 Ord,
7715 Hash,
7716 ::serde::Serialize,
7717 ::serde::Deserialize,
7718 )]
7719 #[repr(i16)]
7720 pub enum TimeUnit {
7721 /// The variant `SECOND` in the enum `TimeUnit`
7722 Second = 0,
7723
7724 /// The variant `MILLISECOND` in the enum `TimeUnit`
7725 Millisecond = 1,
7726
7727 /// The variant `MICROSECOND` in the enum `TimeUnit`
7728 Microsecond = 2,
7729
7730 /// The variant `NANOSECOND` in the enum `TimeUnit`
7731 Nanosecond = 3,
7732 }
7733
7734 impl TimeUnit {
7735 /// Array containing all valid variants of TimeUnit
7736 pub const ENUM_VALUES: [Self; 4] = [
7737 Self::Second,
7738 Self::Millisecond,
7739 Self::Microsecond,
7740 Self::Nanosecond,
7741 ];
7742 }
7743
7744 impl ::core::convert::TryFrom<i16> for TimeUnit {
7745 type Error = ::planus::errors::UnknownEnumTagKind;
7746 #[inline]
7747 fn try_from(
7748 value: i16,
7749 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
7750 {
7751 #[allow(clippy::match_single_binding)]
7752 match value {
7753 0 => ::core::result::Result::Ok(TimeUnit::Second),
7754 1 => ::core::result::Result::Ok(TimeUnit::Millisecond),
7755 2 => ::core::result::Result::Ok(TimeUnit::Microsecond),
7756 3 => ::core::result::Result::Ok(TimeUnit::Nanosecond),
7757
7758 _ => ::core::result::Result::Err(
7759 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
7760 ),
7761 }
7762 }
7763 }
7764
7765 impl ::core::convert::From<TimeUnit> for i16 {
7766 #[inline]
7767 fn from(value: TimeUnit) -> Self {
7768 value as i16
7769 }
7770 }
7771
7772 /// # Safety
7773 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
7774 unsafe impl ::planus::Primitive for TimeUnit {
7775 const ALIGNMENT: usize = 2;
7776 const SIZE: usize = 2;
7777 }
7778
7779 impl ::planus::WriteAsPrimitive<TimeUnit> for TimeUnit {
7780 #[inline]
7781 fn write<const N: usize>(
7782 &self,
7783 cursor: ::planus::Cursor<'_, N>,
7784 buffer_position: u32,
7785 ) {
7786 (*self as i16).write(cursor, buffer_position);
7787 }
7788 }
7789
7790 impl ::planus::WriteAs<TimeUnit> for TimeUnit {
7791 type Prepared = Self;
7792
7793 #[inline]
7794 fn prepare(&self, _builder: &mut ::planus::Builder) -> TimeUnit {
7795 *self
7796 }
7797 }
7798
7799 impl ::planus::WriteAsDefault<TimeUnit, TimeUnit> for TimeUnit {
7800 type Prepared = Self;
7801
7802 #[inline]
7803 fn prepare(
7804 &self,
7805 _builder: &mut ::planus::Builder,
7806 default: &TimeUnit,
7807 ) -> ::core::option::Option<TimeUnit> {
7808 if self == default {
7809 ::core::option::Option::None
7810 } else {
7811 ::core::option::Option::Some(*self)
7812 }
7813 }
7814 }
7815
7816 impl ::planus::WriteAsOptional<TimeUnit> for TimeUnit {
7817 type Prepared = Self;
7818
7819 #[inline]
7820 fn prepare(
7821 &self,
7822 _builder: &mut ::planus::Builder,
7823 ) -> ::core::option::Option<TimeUnit> {
7824 ::core::option::Option::Some(*self)
7825 }
7826 }
7827
7828 impl<'buf> ::planus::TableRead<'buf> for TimeUnit {
7829 #[inline]
7830 fn from_buffer(
7831 buffer: ::planus::SliceWithStartOffset<'buf>,
7832 offset: usize,
7833 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
7834 {
7835 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
7836 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
7837 }
7838 }
7839
7840 impl<'buf> ::planus::VectorReadInner<'buf> for TimeUnit {
7841 type Error = ::planus::errors::UnknownEnumTag;
7842 const STRIDE: usize = 2;
7843 #[inline]
7844 unsafe fn from_buffer(
7845 buffer: ::planus::SliceWithStartOffset<'buf>,
7846 offset: usize,
7847 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
7848 {
7849 let value = unsafe {
7850 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
7851 };
7852 let value: ::core::result::Result<Self, _> =
7853 ::core::convert::TryInto::try_into(value);
7854 value.map_err(|error_kind| {
7855 error_kind.with_error_location(
7856 "TimeUnit",
7857 "VectorRead::from_buffer",
7858 buffer.offset_from_start,
7859 )
7860 })
7861 }
7862 }
7863
7864 /// # Safety
7865 /// The planus compiler generates implementations that initialize
7866 /// the bytes in `write_values`.
7867 unsafe impl ::planus::VectorWrite<TimeUnit> for TimeUnit {
7868 const STRIDE: usize = 2;
7869
7870 type Value = Self;
7871
7872 #[inline]
7873 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
7874 *self
7875 }
7876
7877 #[inline]
7878 unsafe fn write_values(
7879 values: &[Self],
7880 bytes: *mut ::core::mem::MaybeUninit<u8>,
7881 buffer_position: u32,
7882 ) {
7883 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
7884 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
7885 ::planus::WriteAsPrimitive::write(
7886 v,
7887 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
7888 buffer_position - (2 * i) as u32,
7889 );
7890 }
7891 }
7892 }
7893
7894 /// Time is either a 32-bit or 64-bit signed integer type representing an
7895 /// elapsed time since midnight, stored in either of four units: seconds,
7896 /// milliseconds, microseconds or nanoseconds.
7897 ///
7898 /// The integer `bitWidth` depends on the `unit` and must be one of the following:
7899 /// * SECOND and MILLISECOND: 32 bits
7900 /// * MICROSECOND and NANOSECOND: 64 bits
7901 ///
7902 /// The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds
7903 /// (exclusive), adjusted for the time unit (for example, up to 86400000
7904 /// exclusive for the MILLISECOND unit).
7905 /// This definition doesn't allow for leap seconds. Time values from
7906 /// measurements with leap seconds will need to be corrected when ingesting
7907 /// into Arrow (for example by replacing the value 86400 with 86399).
7908 ///
7909 /// Generated from these locations:
7910 /// * Table `Time` in the file `Schema.fbs:272`
7911 #[derive(
7912 Clone,
7913 Debug,
7914 PartialEq,
7915 PartialOrd,
7916 Eq,
7917 Ord,
7918 Hash,
7919 ::serde::Serialize,
7920 ::serde::Deserialize,
7921 )]
7922 pub struct Time {
7923 /// The field `unit` in the table `Time`
7924 pub unit: self::TimeUnit,
7925 /// The field `bitWidth` in the table `Time`
7926 pub bit_width: i32,
7927 }
7928
7929 #[allow(clippy::derivable_impls)]
7930 impl ::core::default::Default for Time {
7931 fn default() -> Self {
7932 Self {
7933 unit: self::TimeUnit::Millisecond,
7934 bit_width: 32,
7935 }
7936 }
7937 }
7938
7939 impl Time {
7940 /// Creates a [TimeBuilder] for serializing an instance of this table.
7941 #[inline]
7942 pub fn builder() -> TimeBuilder<()> {
7943 TimeBuilder(())
7944 }
7945
7946 #[allow(clippy::too_many_arguments)]
7947 pub fn create(
7948 builder: &mut ::planus::Builder,
7949 field_unit: impl ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
7950 field_bit_width: impl ::planus::WriteAsDefault<i32, i32>,
7951 ) -> ::planus::Offset<Self> {
7952 let prepared_unit =
7953 field_unit.prepare(builder, &self::TimeUnit::Millisecond);
7954 let prepared_bit_width = field_bit_width.prepare(builder, &32);
7955
7956 let mut table_writer: ::planus::table_writer::TableWriter<8> =
7957 ::core::default::Default::default();
7958 if prepared_bit_width.is_some() {
7959 table_writer.write_entry::<i32>(1);
7960 }
7961 if prepared_unit.is_some() {
7962 table_writer.write_entry::<self::TimeUnit>(0);
7963 }
7964
7965 unsafe {
7966 table_writer.finish(builder, |object_writer| {
7967 if let ::core::option::Option::Some(prepared_bit_width) =
7968 prepared_bit_width
7969 {
7970 object_writer.write::<_, _, 4>(&prepared_bit_width);
7971 }
7972 if let ::core::option::Option::Some(prepared_unit) =
7973 prepared_unit
7974 {
7975 object_writer.write::<_, _, 2>(&prepared_unit);
7976 }
7977 });
7978 }
7979 builder.current_offset()
7980 }
7981 }
7982
7983 impl ::planus::WriteAs<::planus::Offset<Time>> for Time {
7984 type Prepared = ::planus::Offset<Self>;
7985
7986 #[inline]
7987 fn prepare(
7988 &self,
7989 builder: &mut ::planus::Builder,
7990 ) -> ::planus::Offset<Time> {
7991 ::planus::WriteAsOffset::prepare(self, builder)
7992 }
7993 }
7994
7995 impl ::planus::WriteAsOptional<::planus::Offset<Time>> for Time {
7996 type Prepared = ::planus::Offset<Self>;
7997
7998 #[inline]
7999 fn prepare(
8000 &self,
8001 builder: &mut ::planus::Builder,
8002 ) -> ::core::option::Option<::planus::Offset<Time>>
8003 {
8004 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
8005 self, builder,
8006 ))
8007 }
8008 }
8009
8010 impl ::planus::WriteAsOffset<Time> for Time {
8011 #[inline]
8012 fn prepare(
8013 &self,
8014 builder: &mut ::planus::Builder,
8015 ) -> ::planus::Offset<Time> {
8016 Time::create(builder, self.unit, self.bit_width)
8017 }
8018 }
8019
8020 /// Builder for serializing an instance of the [Time] type.
8021 ///
8022 /// Can be created using the [Time::builder] method.
8023 #[derive(Debug)]
8024 #[must_use]
8025 pub struct TimeBuilder<State>(State);
8026
8027 impl TimeBuilder<()> {
8028 /// Setter for the [`unit` field](Time#structfield.unit).
8029 #[inline]
8030 #[allow(clippy::type_complexity)]
8031 pub fn unit<T0>(self, value: T0) -> TimeBuilder<(T0,)>
8032 where
8033 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8034 {
8035 TimeBuilder((value,))
8036 }
8037
8038 /// Sets the [`unit` field](Time#structfield.unit) to the default value.
8039 #[inline]
8040 #[allow(clippy::type_complexity)]
8041 pub fn unit_as_default(self) -> TimeBuilder<(::planus::DefaultValue,)> {
8042 self.unit(::planus::DefaultValue)
8043 }
8044 }
8045
8046 impl<T0> TimeBuilder<(T0,)> {
8047 /// Setter for the [`bitWidth` field](Time#structfield.bit_width).
8048 #[inline]
8049 #[allow(clippy::type_complexity)]
8050 pub fn bit_width<T1>(self, value: T1) -> TimeBuilder<(T0, T1)>
8051 where
8052 T1: ::planus::WriteAsDefault<i32, i32>,
8053 {
8054 let (v0,) = self.0;
8055 TimeBuilder((v0, value))
8056 }
8057
8058 /// Sets the [`bitWidth` field](Time#structfield.bit_width) to the default value.
8059 #[inline]
8060 #[allow(clippy::type_complexity)]
8061 pub fn bit_width_as_default(
8062 self,
8063 ) -> TimeBuilder<(T0, ::planus::DefaultValue)> {
8064 self.bit_width(::planus::DefaultValue)
8065 }
8066 }
8067
8068 impl<T0, T1> TimeBuilder<(T0, T1)> {
8069 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Time].
8070 #[inline]
8071 pub fn finish(
8072 self,
8073 builder: &mut ::planus::Builder,
8074 ) -> ::planus::Offset<Time>
8075 where
8076 Self: ::planus::WriteAsOffset<Time>,
8077 {
8078 ::planus::WriteAsOffset::prepare(&self, builder)
8079 }
8080 }
8081
8082 impl<
8083 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8084 T1: ::planus::WriteAsDefault<i32, i32>,
8085 > ::planus::WriteAs<::planus::Offset<Time>> for TimeBuilder<(T0, T1)>
8086 {
8087 type Prepared = ::planus::Offset<Time>;
8088
8089 #[inline]
8090 fn prepare(
8091 &self,
8092 builder: &mut ::planus::Builder,
8093 ) -> ::planus::Offset<Time> {
8094 ::planus::WriteAsOffset::prepare(self, builder)
8095 }
8096 }
8097
8098 impl<
8099 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8100 T1: ::planus::WriteAsDefault<i32, i32>,
8101 > ::planus::WriteAsOptional<::planus::Offset<Time>>
8102 for TimeBuilder<(T0, T1)>
8103 {
8104 type Prepared = ::planus::Offset<Time>;
8105
8106 #[inline]
8107 fn prepare(
8108 &self,
8109 builder: &mut ::planus::Builder,
8110 ) -> ::core::option::Option<::planus::Offset<Time>>
8111 {
8112 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
8113 self, builder,
8114 ))
8115 }
8116 }
8117
8118 impl<
8119 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8120 T1: ::planus::WriteAsDefault<i32, i32>,
8121 > ::planus::WriteAsOffset<Time> for TimeBuilder<(T0, T1)>
8122 {
8123 #[inline]
8124 fn prepare(
8125 &self,
8126 builder: &mut ::planus::Builder,
8127 ) -> ::planus::Offset<Time> {
8128 let (v0, v1) = &self.0;
8129 Time::create(builder, v0, v1)
8130 }
8131 }
8132
8133 /// Reference to a deserialized [Time].
8134 #[derive(Copy, Clone)]
8135 pub struct TimeRef<'a>(::planus::table_reader::Table<'a>);
8136
8137 impl<'a> TimeRef<'a> {
8138 /// Getter for the [`unit` field](Time#structfield.unit).
8139 #[inline]
8140 pub fn unit(&self) -> ::planus::Result<self::TimeUnit> {
8141 ::core::result::Result::Ok(
8142 self.0
8143 .access(0, "Time", "unit")?
8144 .unwrap_or(self::TimeUnit::Millisecond),
8145 )
8146 }
8147
8148 /// Getter for the [`bitWidth` field](Time#structfield.bit_width).
8149 #[inline]
8150 pub fn bit_width(&self) -> ::planus::Result<i32> {
8151 ::core::result::Result::Ok(
8152 self.0.access(1, "Time", "bit_width")?.unwrap_or(32),
8153 )
8154 }
8155 }
8156
8157 impl<'a> ::core::fmt::Debug for TimeRef<'a> {
8158 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
8159 let mut f = f.debug_struct("TimeRef");
8160 f.field("unit", &self.unit());
8161 f.field("bit_width", &self.bit_width());
8162 f.finish()
8163 }
8164 }
8165
8166 impl<'a> ::core::convert::TryFrom<TimeRef<'a>> for Time {
8167 type Error = ::planus::Error;
8168
8169 #[allow(unreachable_code)]
8170 fn try_from(value: TimeRef<'a>) -> ::planus::Result<Self> {
8171 ::core::result::Result::Ok(Self {
8172 unit: ::core::convert::TryInto::try_into(value.unit()?)?,
8173 bit_width: ::core::convert::TryInto::try_into(value.bit_width()?)?,
8174 })
8175 }
8176 }
8177
8178 impl<'a> ::planus::TableRead<'a> for TimeRef<'a> {
8179 #[inline]
8180 fn from_buffer(
8181 buffer: ::planus::SliceWithStartOffset<'a>,
8182 offset: usize,
8183 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
8184 {
8185 ::core::result::Result::Ok(Self(
8186 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
8187 ))
8188 }
8189 }
8190
8191 impl<'a> ::planus::VectorReadInner<'a> for TimeRef<'a> {
8192 type Error = ::planus::Error;
8193 const STRIDE: usize = 4;
8194
8195 unsafe fn from_buffer(
8196 buffer: ::planus::SliceWithStartOffset<'a>,
8197 offset: usize,
8198 ) -> ::planus::Result<Self> {
8199 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
8200 error_kind.with_error_location(
8201 "[TimeRef]",
8202 "get",
8203 buffer.offset_from_start,
8204 )
8205 })
8206 }
8207 }
8208
8209 /// # Safety
8210 /// The planus compiler generates implementations that initialize
8211 /// the bytes in `write_values`.
8212 unsafe impl ::planus::VectorWrite<::planus::Offset<Time>> for Time {
8213 type Value = ::planus::Offset<Time>;
8214 const STRIDE: usize = 4;
8215 #[inline]
8216 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
8217 ::planus::WriteAs::prepare(self, builder)
8218 }
8219
8220 #[inline]
8221 unsafe fn write_values(
8222 values: &[::planus::Offset<Time>],
8223 bytes: *mut ::core::mem::MaybeUninit<u8>,
8224 buffer_position: u32,
8225 ) {
8226 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
8227 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
8228 ::planus::WriteAsPrimitive::write(
8229 v,
8230 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
8231 buffer_position - (Self::STRIDE * i) as u32,
8232 );
8233 }
8234 }
8235 }
8236
8237 impl<'a> ::planus::ReadAsRoot<'a> for TimeRef<'a> {
8238 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
8239 ::planus::TableRead::from_buffer(
8240 ::planus::SliceWithStartOffset {
8241 buffer: slice,
8242 offset_from_start: 0,
8243 },
8244 0,
8245 )
8246 .map_err(|error_kind| {
8247 error_kind.with_error_location("[TimeRef]", "read_as_root", 0)
8248 })
8249 }
8250 }
8251
8252 /// Timestamp is a 64-bit signed integer representing an elapsed time since a
8253 /// fixed epoch, stored in either of four units: seconds, milliseconds,
8254 /// microseconds or nanoseconds, and is optionally annotated with a timezone.
8255 ///
8256 /// Timestamp values do not include any leap seconds (in other words, all
8257 /// days are considered 86400 seconds long).
8258 ///
8259 /// Timestamps with a non-empty timezone
8260 /// ------------------------------------
8261 ///
8262 /// If a Timestamp column has a non-empty timezone value, its epoch is
8263 /// 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone
8264 /// (the Unix epoch), regardless of the Timestamp's own timezone.
8265 ///
8266 /// Therefore, timestamp values with a non-empty timezone correspond to
8267 /// physical points in time together with some additional information about
8268 /// how the data was obtained and/or how to display it (the timezone).
8269 ///
8270 /// For example, the timestamp value 0 with the timezone string "Europe/Paris"
8271 /// corresponds to "January 1st 1970, 00h00" in the UTC timezone, but the
8272 /// application may prefer to display it as "January 1st 1970, 01h00" in
8273 /// the Europe/Paris timezone (which is the same physical point in time).
8274 ///
8275 /// One consequence is that timestamp values with a non-empty timezone
8276 /// can be compared and ordered directly, since they all share the same
8277 /// well-known point of reference (the Unix epoch).
8278 ///
8279 /// Timestamps with an unset / empty timezone
8280 /// -----------------------------------------
8281 ///
8282 /// If a Timestamp column has no timezone value, its epoch is
8283 /// 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone.
8284 ///
8285 /// Therefore, timestamp values without a timezone cannot be meaningfully
8286 /// interpreted as physical points in time, but only as calendar / clock
8287 /// indications ("wall clock time") in an unspecified timezone.
8288 ///
8289 /// For example, the timestamp value 0 with an empty timezone string
8290 /// corresponds to "January 1st 1970, 00h00" in an unknown timezone: there
8291 /// is not enough information to interpret it as a well-defined physical
8292 /// point in time.
8293 ///
8294 /// One consequence is that timestamp values without a timezone cannot
8295 /// be reliably compared or ordered, since they may have different points of
8296 /// reference. In particular, it is *not* possible to interpret an unset
8297 /// or empty timezone as the same as "UTC".
8298 ///
8299 /// Conversion between timezones
8300 /// ----------------------------
8301 ///
8302 /// If a Timestamp column has a non-empty timezone, changing the timezone
8303 /// to a different non-empty value is a metadata-only operation:
8304 /// the timestamp values need not change as their point of reference remains
8305 /// the same (the Unix epoch).
8306 ///
8307 /// However, if a Timestamp column has no timezone value, changing it to a
8308 /// non-empty value requires to think about the desired semantics.
8309 /// One possibility is to assume that the original timestamp values are
8310 /// relative to the epoch of the timezone being set; timestamp values should
8311 /// then adjusted to the Unix epoch (for example, changing the timezone from
8312 /// empty to "Europe/Paris" would require converting the timestamp values
8313 /// from "Europe/Paris" to "UTC", which seems counter-intuitive but is
8314 /// nevertheless correct).
8315 ///
8316 /// Guidelines for encoding data from external libraries
8317 /// ----------------------------------------------------
8318 ///
8319 /// Date & time libraries often have multiple different data types for temporal
8320 /// data. In order to ease interoperability between different implementations the
8321 /// Arrow project has some recommendations for encoding these types into a Timestamp
8322 /// column.
8323 ///
8324 /// An "instant" represents a physical point in time that has no relevant timezone
8325 /// (for example, astronomical data). To encode an instant, use a Timestamp with
8326 /// the timezone string set to "UTC", and make sure the Timestamp values
8327 /// are relative to the UTC epoch (January 1st 1970, midnight).
8328 ///
8329 /// A "zoned date-time" represents a physical point in time annotated with an
8330 /// informative timezone (for example, the timezone in which the data was
8331 /// recorded). To encode a zoned date-time, use a Timestamp with the timezone
8332 /// string set to the name of the timezone, and make sure the Timestamp values
8333 /// are relative to the UTC epoch (January 1st 1970, midnight).
8334 ///
8335 /// (There is some ambiguity between an instant and a zoned date-time with the
8336 /// UTC timezone. Both of these are stored the same in Arrow. Typically,
8337 /// this distinction does not matter. If it does, then an application should
8338 /// use custom metadata or an extension type to distinguish between the two cases.)
8339 ///
8340 /// An "offset date-time" represents a physical point in time combined with an
8341 /// explicit offset from UTC. To encode an offset date-time, use a Timestamp
8342 /// with the timezone string set to the numeric timezone offset string
8343 /// (e.g. "+03:00"), and make sure the Timestamp values are relative to
8344 /// the UTC epoch (January 1st 1970, midnight).
8345 ///
8346 /// A "naive date-time" (also called "local date-time" in some libraries)
8347 /// represents a wall clock time combined with a calendar date, but with
8348 /// no indication of how to map this information to a physical point in time.
8349 /// Naive date-times must be handled with care because of this missing
8350 /// information, and also because daylight saving time (DST) may make
8351 /// some values ambiguous or nonexistent. A naive date-time may be
8352 /// stored as a struct with Date and Time fields. However, it may also be
8353 /// encoded into a Timestamp column with an empty timezone. The timestamp
8354 /// values should be computed "as if" the timezone of the date-time values
8355 /// was UTC; for example, the naive date-time "January 1st 1970, 00h00" would
8356 /// be encoded as timestamp value 0.
8357 ///
8358 /// Generated from these locations:
8359 /// * Table `Timestamp` in the file `Schema.fbs:382`
8360 #[derive(
8361 Clone,
8362 Debug,
8363 PartialEq,
8364 PartialOrd,
8365 Eq,
8366 Ord,
8367 Hash,
8368 ::serde::Serialize,
8369 ::serde::Deserialize,
8370 )]
8371 pub struct Timestamp {
8372 /// The field `unit` in the table `Timestamp`
8373 pub unit: self::TimeUnit,
8374 /// The timezone is an optional string indicating the name of a timezone,
8375 /// one of:
8376 ///
8377 /// * As used in the Olson timezone database (the "tz database" or
8378 /// "tzdata"), such as "America/New_York".
8379 /// * An absolute timezone offset of the form "+XX:XX" or "-XX:XX",
8380 /// such as "+07:30".
8381 ///
8382 /// Whether a timezone string is present indicates different semantics about
8383 /// the data (see above).
8384 pub timezone: ::core::option::Option<::planus::alloc::string::String>,
8385 }
8386
8387 #[allow(clippy::derivable_impls)]
8388 impl ::core::default::Default for Timestamp {
8389 fn default() -> Self {
8390 Self {
8391 unit: self::TimeUnit::Second,
8392 timezone: ::core::default::Default::default(),
8393 }
8394 }
8395 }
8396
8397 impl Timestamp {
8398 /// Creates a [TimestampBuilder] for serializing an instance of this table.
8399 #[inline]
8400 pub fn builder() -> TimestampBuilder<()> {
8401 TimestampBuilder(())
8402 }
8403
8404 #[allow(clippy::too_many_arguments)]
8405 pub fn create(
8406 builder: &mut ::planus::Builder,
8407 field_unit: impl ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8408 field_timezone: impl ::planus::WriteAsOptional<
8409 ::planus::Offset<::core::primitive::str>,
8410 >,
8411 ) -> ::planus::Offset<Self> {
8412 let prepared_unit =
8413 field_unit.prepare(builder, &self::TimeUnit::Second);
8414 let prepared_timezone = field_timezone.prepare(builder);
8415
8416 let mut table_writer: ::planus::table_writer::TableWriter<8> =
8417 ::core::default::Default::default();
8418 if prepared_timezone.is_some() {
8419 table_writer.write_entry::<::planus::Offset<str>>(1);
8420 }
8421 if prepared_unit.is_some() {
8422 table_writer.write_entry::<self::TimeUnit>(0);
8423 }
8424
8425 unsafe {
8426 table_writer.finish(builder, |object_writer| {
8427 if let ::core::option::Option::Some(prepared_timezone) =
8428 prepared_timezone
8429 {
8430 object_writer.write::<_, _, 4>(&prepared_timezone);
8431 }
8432 if let ::core::option::Option::Some(prepared_unit) =
8433 prepared_unit
8434 {
8435 object_writer.write::<_, _, 2>(&prepared_unit);
8436 }
8437 });
8438 }
8439 builder.current_offset()
8440 }
8441 }
8442
8443 impl ::planus::WriteAs<::planus::Offset<Timestamp>> for Timestamp {
8444 type Prepared = ::planus::Offset<Self>;
8445
8446 #[inline]
8447 fn prepare(
8448 &self,
8449 builder: &mut ::planus::Builder,
8450 ) -> ::planus::Offset<Timestamp> {
8451 ::planus::WriteAsOffset::prepare(self, builder)
8452 }
8453 }
8454
8455 impl ::planus::WriteAsOptional<::planus::Offset<Timestamp>> for Timestamp {
8456 type Prepared = ::planus::Offset<Self>;
8457
8458 #[inline]
8459 fn prepare(
8460 &self,
8461 builder: &mut ::planus::Builder,
8462 ) -> ::core::option::Option<::planus::Offset<Timestamp>>
8463 {
8464 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
8465 self, builder,
8466 ))
8467 }
8468 }
8469
8470 impl ::planus::WriteAsOffset<Timestamp> for Timestamp {
8471 #[inline]
8472 fn prepare(
8473 &self,
8474 builder: &mut ::planus::Builder,
8475 ) -> ::planus::Offset<Timestamp> {
8476 Timestamp::create(builder, self.unit, &self.timezone)
8477 }
8478 }
8479
8480 /// Builder for serializing an instance of the [Timestamp] type.
8481 ///
8482 /// Can be created using the [Timestamp::builder] method.
8483 #[derive(Debug)]
8484 #[must_use]
8485 pub struct TimestampBuilder<State>(State);
8486
8487 impl TimestampBuilder<()> {
8488 /// Setter for the [`unit` field](Timestamp#structfield.unit).
8489 #[inline]
8490 #[allow(clippy::type_complexity)]
8491 pub fn unit<T0>(self, value: T0) -> TimestampBuilder<(T0,)>
8492 where
8493 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8494 {
8495 TimestampBuilder((value,))
8496 }
8497
8498 /// Sets the [`unit` field](Timestamp#structfield.unit) to the default value.
8499 #[inline]
8500 #[allow(clippy::type_complexity)]
8501 pub fn unit_as_default(
8502 self,
8503 ) -> TimestampBuilder<(::planus::DefaultValue,)> {
8504 self.unit(::planus::DefaultValue)
8505 }
8506 }
8507
8508 impl<T0> TimestampBuilder<(T0,)> {
8509 /// Setter for the [`timezone` field](Timestamp#structfield.timezone).
8510 #[inline]
8511 #[allow(clippy::type_complexity)]
8512 pub fn timezone<T1>(self, value: T1) -> TimestampBuilder<(T0, T1)>
8513 where
8514 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
8515 {
8516 let (v0,) = self.0;
8517 TimestampBuilder((v0, value))
8518 }
8519
8520 /// Sets the [`timezone` field](Timestamp#structfield.timezone) to null.
8521 #[inline]
8522 #[allow(clippy::type_complexity)]
8523 pub fn timezone_as_null(self) -> TimestampBuilder<(T0, ())> {
8524 self.timezone(())
8525 }
8526 }
8527
8528 impl<T0, T1> TimestampBuilder<(T0, T1)> {
8529 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Timestamp].
8530 #[inline]
8531 pub fn finish(
8532 self,
8533 builder: &mut ::planus::Builder,
8534 ) -> ::planus::Offset<Timestamp>
8535 where
8536 Self: ::planus::WriteAsOffset<Timestamp>,
8537 {
8538 ::planus::WriteAsOffset::prepare(&self, builder)
8539 }
8540 }
8541
8542 impl<
8543 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8544 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
8545 > ::planus::WriteAs<::planus::Offset<Timestamp>>
8546 for TimestampBuilder<(T0, T1)>
8547 {
8548 type Prepared = ::planus::Offset<Timestamp>;
8549
8550 #[inline]
8551 fn prepare(
8552 &self,
8553 builder: &mut ::planus::Builder,
8554 ) -> ::planus::Offset<Timestamp> {
8555 ::planus::WriteAsOffset::prepare(self, builder)
8556 }
8557 }
8558
8559 impl<
8560 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8561 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
8562 > ::planus::WriteAsOptional<::planus::Offset<Timestamp>>
8563 for TimestampBuilder<(T0, T1)>
8564 {
8565 type Prepared = ::planus::Offset<Timestamp>;
8566
8567 #[inline]
8568 fn prepare(
8569 &self,
8570 builder: &mut ::planus::Builder,
8571 ) -> ::core::option::Option<::planus::Offset<Timestamp>>
8572 {
8573 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
8574 self, builder,
8575 ))
8576 }
8577 }
8578
8579 impl<
8580 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
8581 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
8582 > ::planus::WriteAsOffset<Timestamp> for TimestampBuilder<(T0, T1)>
8583 {
8584 #[inline]
8585 fn prepare(
8586 &self,
8587 builder: &mut ::planus::Builder,
8588 ) -> ::planus::Offset<Timestamp> {
8589 let (v0, v1) = &self.0;
8590 Timestamp::create(builder, v0, v1)
8591 }
8592 }
8593
8594 /// Reference to a deserialized [Timestamp].
8595 #[derive(Copy, Clone)]
8596 pub struct TimestampRef<'a>(::planus::table_reader::Table<'a>);
8597
8598 impl<'a> TimestampRef<'a> {
8599 /// Getter for the [`unit` field](Timestamp#structfield.unit).
8600 #[inline]
8601 pub fn unit(&self) -> ::planus::Result<self::TimeUnit> {
8602 ::core::result::Result::Ok(
8603 self.0
8604 .access(0, "Timestamp", "unit")?
8605 .unwrap_or(self::TimeUnit::Second),
8606 )
8607 }
8608
8609 /// Getter for the [`timezone` field](Timestamp#structfield.timezone).
8610 #[inline]
8611 pub fn timezone(
8612 &self,
8613 ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>>
8614 {
8615 self.0.access(1, "Timestamp", "timezone")
8616 }
8617 }
8618
8619 impl<'a> ::core::fmt::Debug for TimestampRef<'a> {
8620 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
8621 let mut f = f.debug_struct("TimestampRef");
8622 f.field("unit", &self.unit());
8623 if let ::core::option::Option::Some(field_timezone) =
8624 self.timezone().transpose()
8625 {
8626 f.field("timezone", &field_timezone);
8627 }
8628 f.finish()
8629 }
8630 }
8631
8632 impl<'a> ::core::convert::TryFrom<TimestampRef<'a>> for Timestamp {
8633 type Error = ::planus::Error;
8634
8635 #[allow(unreachable_code)]
8636 fn try_from(value: TimestampRef<'a>) -> ::planus::Result<Self> {
8637 ::core::result::Result::Ok(Self {
8638 unit: ::core::convert::TryInto::try_into(value.unit()?)?,
8639 timezone: value.timezone()?.map(::core::convert::Into::into),
8640 })
8641 }
8642 }
8643
8644 impl<'a> ::planus::TableRead<'a> for TimestampRef<'a> {
8645 #[inline]
8646 fn from_buffer(
8647 buffer: ::planus::SliceWithStartOffset<'a>,
8648 offset: usize,
8649 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
8650 {
8651 ::core::result::Result::Ok(Self(
8652 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
8653 ))
8654 }
8655 }
8656
8657 impl<'a> ::planus::VectorReadInner<'a> for TimestampRef<'a> {
8658 type Error = ::planus::Error;
8659 const STRIDE: usize = 4;
8660
8661 unsafe fn from_buffer(
8662 buffer: ::planus::SliceWithStartOffset<'a>,
8663 offset: usize,
8664 ) -> ::planus::Result<Self> {
8665 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
8666 error_kind.with_error_location(
8667 "[TimestampRef]",
8668 "get",
8669 buffer.offset_from_start,
8670 )
8671 })
8672 }
8673 }
8674
8675 /// # Safety
8676 /// The planus compiler generates implementations that initialize
8677 /// the bytes in `write_values`.
8678 unsafe impl ::planus::VectorWrite<::planus::Offset<Timestamp>> for Timestamp {
8679 type Value = ::planus::Offset<Timestamp>;
8680 const STRIDE: usize = 4;
8681 #[inline]
8682 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
8683 ::planus::WriteAs::prepare(self, builder)
8684 }
8685
8686 #[inline]
8687 unsafe fn write_values(
8688 values: &[::planus::Offset<Timestamp>],
8689 bytes: *mut ::core::mem::MaybeUninit<u8>,
8690 buffer_position: u32,
8691 ) {
8692 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
8693 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
8694 ::planus::WriteAsPrimitive::write(
8695 v,
8696 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
8697 buffer_position - (Self::STRIDE * i) as u32,
8698 );
8699 }
8700 }
8701 }
8702
8703 impl<'a> ::planus::ReadAsRoot<'a> for TimestampRef<'a> {
8704 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
8705 ::planus::TableRead::from_buffer(
8706 ::planus::SliceWithStartOffset {
8707 buffer: slice,
8708 offset_from_start: 0,
8709 },
8710 0,
8711 )
8712 .map_err(|error_kind| {
8713 error_kind.with_error_location("[TimestampRef]", "read_as_root", 0)
8714 })
8715 }
8716 }
8717
8718 /// The enum `IntervalUnit` in the namespace `org.apache.arrow.flatbuf`
8719 ///
8720 /// Generated from these locations:
8721 /// * Enum `IntervalUnit` in the file `Schema.fbs:398`
8722 #[derive(
8723 Copy,
8724 Clone,
8725 Debug,
8726 PartialEq,
8727 Eq,
8728 PartialOrd,
8729 Ord,
8730 Hash,
8731 ::serde::Serialize,
8732 ::serde::Deserialize,
8733 )]
8734 #[repr(i16)]
8735 pub enum IntervalUnit {
8736 /// The variant `YEAR_MONTH` in the enum `IntervalUnit`
8737 YearMonth = 0,
8738
8739 /// The variant `DAY_TIME` in the enum `IntervalUnit`
8740 DayTime = 1,
8741
8742 /// The variant `MONTH_DAY_NANO` in the enum `IntervalUnit`
8743 MonthDayNano = 2,
8744 }
8745
8746 impl IntervalUnit {
8747 /// Array containing all valid variants of IntervalUnit
8748 pub const ENUM_VALUES: [Self; 3] =
8749 [Self::YearMonth, Self::DayTime, Self::MonthDayNano];
8750 }
8751
8752 impl ::core::convert::TryFrom<i16> for IntervalUnit {
8753 type Error = ::planus::errors::UnknownEnumTagKind;
8754 #[inline]
8755 fn try_from(
8756 value: i16,
8757 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
8758 {
8759 #[allow(clippy::match_single_binding)]
8760 match value {
8761 0 => ::core::result::Result::Ok(IntervalUnit::YearMonth),
8762 1 => ::core::result::Result::Ok(IntervalUnit::DayTime),
8763 2 => ::core::result::Result::Ok(IntervalUnit::MonthDayNano),
8764
8765 _ => ::core::result::Result::Err(
8766 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
8767 ),
8768 }
8769 }
8770 }
8771
8772 impl ::core::convert::From<IntervalUnit> for i16 {
8773 #[inline]
8774 fn from(value: IntervalUnit) -> Self {
8775 value as i16
8776 }
8777 }
8778
8779 /// # Safety
8780 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
8781 unsafe impl ::planus::Primitive for IntervalUnit {
8782 const ALIGNMENT: usize = 2;
8783 const SIZE: usize = 2;
8784 }
8785
8786 impl ::planus::WriteAsPrimitive<IntervalUnit> for IntervalUnit {
8787 #[inline]
8788 fn write<const N: usize>(
8789 &self,
8790 cursor: ::planus::Cursor<'_, N>,
8791 buffer_position: u32,
8792 ) {
8793 (*self as i16).write(cursor, buffer_position);
8794 }
8795 }
8796
8797 impl ::planus::WriteAs<IntervalUnit> for IntervalUnit {
8798 type Prepared = Self;
8799
8800 #[inline]
8801 fn prepare(&self, _builder: &mut ::planus::Builder) -> IntervalUnit {
8802 *self
8803 }
8804 }
8805
8806 impl ::planus::WriteAsDefault<IntervalUnit, IntervalUnit> for IntervalUnit {
8807 type Prepared = Self;
8808
8809 #[inline]
8810 fn prepare(
8811 &self,
8812 _builder: &mut ::planus::Builder,
8813 default: &IntervalUnit,
8814 ) -> ::core::option::Option<IntervalUnit> {
8815 if self == default {
8816 ::core::option::Option::None
8817 } else {
8818 ::core::option::Option::Some(*self)
8819 }
8820 }
8821 }
8822
8823 impl ::planus::WriteAsOptional<IntervalUnit> for IntervalUnit {
8824 type Prepared = Self;
8825
8826 #[inline]
8827 fn prepare(
8828 &self,
8829 _builder: &mut ::planus::Builder,
8830 ) -> ::core::option::Option<IntervalUnit> {
8831 ::core::option::Option::Some(*self)
8832 }
8833 }
8834
8835 impl<'buf> ::planus::TableRead<'buf> for IntervalUnit {
8836 #[inline]
8837 fn from_buffer(
8838 buffer: ::planus::SliceWithStartOffset<'buf>,
8839 offset: usize,
8840 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
8841 {
8842 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
8843 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
8844 }
8845 }
8846
8847 impl<'buf> ::planus::VectorReadInner<'buf> for IntervalUnit {
8848 type Error = ::planus::errors::UnknownEnumTag;
8849 const STRIDE: usize = 2;
8850 #[inline]
8851 unsafe fn from_buffer(
8852 buffer: ::planus::SliceWithStartOffset<'buf>,
8853 offset: usize,
8854 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
8855 {
8856 let value = unsafe {
8857 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
8858 };
8859 let value: ::core::result::Result<Self, _> =
8860 ::core::convert::TryInto::try_into(value);
8861 value.map_err(|error_kind| {
8862 error_kind.with_error_location(
8863 "IntervalUnit",
8864 "VectorRead::from_buffer",
8865 buffer.offset_from_start,
8866 )
8867 })
8868 }
8869 }
8870
8871 /// # Safety
8872 /// The planus compiler generates implementations that initialize
8873 /// the bytes in `write_values`.
8874 unsafe impl ::planus::VectorWrite<IntervalUnit> for IntervalUnit {
8875 const STRIDE: usize = 2;
8876
8877 type Value = Self;
8878
8879 #[inline]
8880 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
8881 *self
8882 }
8883
8884 #[inline]
8885 unsafe fn write_values(
8886 values: &[Self],
8887 bytes: *mut ::core::mem::MaybeUninit<u8>,
8888 buffer_position: u32,
8889 ) {
8890 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
8891 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
8892 ::planus::WriteAsPrimitive::write(
8893 v,
8894 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
8895 buffer_position - (2 * i) as u32,
8896 );
8897 }
8898 }
8899 }
8900
8901 /// The table `Interval` in the namespace `org.apache.arrow.flatbuf`
8902 ///
8903 /// Generated from these locations:
8904 /// * Table `Interval` in the file `Schema.fbs:417`
8905 #[derive(
8906 Clone,
8907 Debug,
8908 PartialEq,
8909 PartialOrd,
8910 Eq,
8911 Ord,
8912 Hash,
8913 ::serde::Serialize,
8914 ::serde::Deserialize,
8915 )]
8916 pub struct Interval {
8917 /// The field `unit` in the table `Interval`
8918 pub unit: self::IntervalUnit,
8919 }
8920
8921 #[allow(clippy::derivable_impls)]
8922 impl ::core::default::Default for Interval {
8923 fn default() -> Self {
8924 Self {
8925 unit: self::IntervalUnit::YearMonth,
8926 }
8927 }
8928 }
8929
8930 impl Interval {
8931 /// Creates a [IntervalBuilder] for serializing an instance of this table.
8932 #[inline]
8933 pub fn builder() -> IntervalBuilder<()> {
8934 IntervalBuilder(())
8935 }
8936
8937 #[allow(clippy::too_many_arguments)]
8938 pub fn create(
8939 builder: &mut ::planus::Builder,
8940 field_unit: impl ::planus::WriteAsDefault<
8941 self::IntervalUnit,
8942 self::IntervalUnit,
8943 >,
8944 ) -> ::planus::Offset<Self> {
8945 let prepared_unit =
8946 field_unit.prepare(builder, &self::IntervalUnit::YearMonth);
8947
8948 let mut table_writer: ::planus::table_writer::TableWriter<6> =
8949 ::core::default::Default::default();
8950 if prepared_unit.is_some() {
8951 table_writer.write_entry::<self::IntervalUnit>(0);
8952 }
8953
8954 unsafe {
8955 table_writer.finish(builder, |object_writer| {
8956 if let ::core::option::Option::Some(prepared_unit) =
8957 prepared_unit
8958 {
8959 object_writer.write::<_, _, 2>(&prepared_unit);
8960 }
8961 });
8962 }
8963 builder.current_offset()
8964 }
8965 }
8966
8967 impl ::planus::WriteAs<::planus::Offset<Interval>> for Interval {
8968 type Prepared = ::planus::Offset<Self>;
8969
8970 #[inline]
8971 fn prepare(
8972 &self,
8973 builder: &mut ::planus::Builder,
8974 ) -> ::planus::Offset<Interval> {
8975 ::planus::WriteAsOffset::prepare(self, builder)
8976 }
8977 }
8978
8979 impl ::planus::WriteAsOptional<::planus::Offset<Interval>> for Interval {
8980 type Prepared = ::planus::Offset<Self>;
8981
8982 #[inline]
8983 fn prepare(
8984 &self,
8985 builder: &mut ::planus::Builder,
8986 ) -> ::core::option::Option<::planus::Offset<Interval>>
8987 {
8988 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
8989 self, builder,
8990 ))
8991 }
8992 }
8993
8994 impl ::planus::WriteAsOffset<Interval> for Interval {
8995 #[inline]
8996 fn prepare(
8997 &self,
8998 builder: &mut ::planus::Builder,
8999 ) -> ::planus::Offset<Interval> {
9000 Interval::create(builder, self.unit)
9001 }
9002 }
9003
9004 /// Builder for serializing an instance of the [Interval] type.
9005 ///
9006 /// Can be created using the [Interval::builder] method.
9007 #[derive(Debug)]
9008 #[must_use]
9009 pub struct IntervalBuilder<State>(State);
9010
9011 impl IntervalBuilder<()> {
9012 /// Setter for the [`unit` field](Interval#structfield.unit).
9013 #[inline]
9014 #[allow(clippy::type_complexity)]
9015 pub fn unit<T0>(self, value: T0) -> IntervalBuilder<(T0,)>
9016 where
9017 T0: ::planus::WriteAsDefault<self::IntervalUnit, self::IntervalUnit>,
9018 {
9019 IntervalBuilder((value,))
9020 }
9021
9022 /// Sets the [`unit` field](Interval#structfield.unit) to the default value.
9023 #[inline]
9024 #[allow(clippy::type_complexity)]
9025 pub fn unit_as_default(self) -> IntervalBuilder<(::planus::DefaultValue,)> {
9026 self.unit(::planus::DefaultValue)
9027 }
9028 }
9029
9030 impl<T0> IntervalBuilder<(T0,)> {
9031 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Interval].
9032 #[inline]
9033 pub fn finish(
9034 self,
9035 builder: &mut ::planus::Builder,
9036 ) -> ::planus::Offset<Interval>
9037 where
9038 Self: ::planus::WriteAsOffset<Interval>,
9039 {
9040 ::planus::WriteAsOffset::prepare(&self, builder)
9041 }
9042 }
9043
9044 impl<T0: ::planus::WriteAsDefault<self::IntervalUnit, self::IntervalUnit>>
9045 ::planus::WriteAs<::planus::Offset<Interval>> for IntervalBuilder<(T0,)>
9046 {
9047 type Prepared = ::planus::Offset<Interval>;
9048
9049 #[inline]
9050 fn prepare(
9051 &self,
9052 builder: &mut ::planus::Builder,
9053 ) -> ::planus::Offset<Interval> {
9054 ::planus::WriteAsOffset::prepare(self, builder)
9055 }
9056 }
9057
9058 impl<T0: ::planus::WriteAsDefault<self::IntervalUnit, self::IntervalUnit>>
9059 ::planus::WriteAsOptional<::planus::Offset<Interval>>
9060 for IntervalBuilder<(T0,)>
9061 {
9062 type Prepared = ::planus::Offset<Interval>;
9063
9064 #[inline]
9065 fn prepare(
9066 &self,
9067 builder: &mut ::planus::Builder,
9068 ) -> ::core::option::Option<::planus::Offset<Interval>>
9069 {
9070 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
9071 self, builder,
9072 ))
9073 }
9074 }
9075
9076 impl<T0: ::planus::WriteAsDefault<self::IntervalUnit, self::IntervalUnit>>
9077 ::planus::WriteAsOffset<Interval> for IntervalBuilder<(T0,)>
9078 {
9079 #[inline]
9080 fn prepare(
9081 &self,
9082 builder: &mut ::planus::Builder,
9083 ) -> ::planus::Offset<Interval> {
9084 let (v0,) = &self.0;
9085 Interval::create(builder, v0)
9086 }
9087 }
9088
9089 /// Reference to a deserialized [Interval].
9090 #[derive(Copy, Clone)]
9091 pub struct IntervalRef<'a>(::planus::table_reader::Table<'a>);
9092
9093 impl<'a> IntervalRef<'a> {
9094 /// Getter for the [`unit` field](Interval#structfield.unit).
9095 #[inline]
9096 pub fn unit(&self) -> ::planus::Result<self::IntervalUnit> {
9097 ::core::result::Result::Ok(
9098 self.0
9099 .access(0, "Interval", "unit")?
9100 .unwrap_or(self::IntervalUnit::YearMonth),
9101 )
9102 }
9103 }
9104
9105 impl<'a> ::core::fmt::Debug for IntervalRef<'a> {
9106 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
9107 let mut f = f.debug_struct("IntervalRef");
9108 f.field("unit", &self.unit());
9109 f.finish()
9110 }
9111 }
9112
9113 impl<'a> ::core::convert::TryFrom<IntervalRef<'a>> for Interval {
9114 type Error = ::planus::Error;
9115
9116 #[allow(unreachable_code)]
9117 fn try_from(value: IntervalRef<'a>) -> ::planus::Result<Self> {
9118 ::core::result::Result::Ok(Self {
9119 unit: ::core::convert::TryInto::try_into(value.unit()?)?,
9120 })
9121 }
9122 }
9123
9124 impl<'a> ::planus::TableRead<'a> for IntervalRef<'a> {
9125 #[inline]
9126 fn from_buffer(
9127 buffer: ::planus::SliceWithStartOffset<'a>,
9128 offset: usize,
9129 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
9130 {
9131 ::core::result::Result::Ok(Self(
9132 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
9133 ))
9134 }
9135 }
9136
9137 impl<'a> ::planus::VectorReadInner<'a> for IntervalRef<'a> {
9138 type Error = ::planus::Error;
9139 const STRIDE: usize = 4;
9140
9141 unsafe fn from_buffer(
9142 buffer: ::planus::SliceWithStartOffset<'a>,
9143 offset: usize,
9144 ) -> ::planus::Result<Self> {
9145 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
9146 error_kind.with_error_location(
9147 "[IntervalRef]",
9148 "get",
9149 buffer.offset_from_start,
9150 )
9151 })
9152 }
9153 }
9154
9155 /// # Safety
9156 /// The planus compiler generates implementations that initialize
9157 /// the bytes in `write_values`.
9158 unsafe impl ::planus::VectorWrite<::planus::Offset<Interval>> for Interval {
9159 type Value = ::planus::Offset<Interval>;
9160 const STRIDE: usize = 4;
9161 #[inline]
9162 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
9163 ::planus::WriteAs::prepare(self, builder)
9164 }
9165
9166 #[inline]
9167 unsafe fn write_values(
9168 values: &[::planus::Offset<Interval>],
9169 bytes: *mut ::core::mem::MaybeUninit<u8>,
9170 buffer_position: u32,
9171 ) {
9172 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
9173 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
9174 ::planus::WriteAsPrimitive::write(
9175 v,
9176 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
9177 buffer_position - (Self::STRIDE * i) as u32,
9178 );
9179 }
9180 }
9181 }
9182
9183 impl<'a> ::planus::ReadAsRoot<'a> for IntervalRef<'a> {
9184 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
9185 ::planus::TableRead::from_buffer(
9186 ::planus::SliceWithStartOffset {
9187 buffer: slice,
9188 offset_from_start: 0,
9189 },
9190 0,
9191 )
9192 .map_err(|error_kind| {
9193 error_kind.with_error_location("[IntervalRef]", "read_as_root", 0)
9194 })
9195 }
9196 }
9197
9198 /// The table `Duration` in the namespace `org.apache.arrow.flatbuf`
9199 ///
9200 /// Generated from these locations:
9201 /// * Table `Duration` in the file `Schema.fbs:434`
9202 #[derive(
9203 Clone,
9204 Debug,
9205 PartialEq,
9206 PartialOrd,
9207 Eq,
9208 Ord,
9209 Hash,
9210 ::serde::Serialize,
9211 ::serde::Deserialize,
9212 )]
9213 pub struct Duration {
9214 /// The field `unit` in the table `Duration`
9215 pub unit: self::TimeUnit,
9216 }
9217
9218 #[allow(clippy::derivable_impls)]
9219 impl ::core::default::Default for Duration {
9220 fn default() -> Self {
9221 Self {
9222 unit: self::TimeUnit::Millisecond,
9223 }
9224 }
9225 }
9226
9227 impl Duration {
9228 /// Creates a [DurationBuilder] for serializing an instance of this table.
9229 #[inline]
9230 pub fn builder() -> DurationBuilder<()> {
9231 DurationBuilder(())
9232 }
9233
9234 #[allow(clippy::too_many_arguments)]
9235 pub fn create(
9236 builder: &mut ::planus::Builder,
9237 field_unit: impl ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
9238 ) -> ::planus::Offset<Self> {
9239 let prepared_unit =
9240 field_unit.prepare(builder, &self::TimeUnit::Millisecond);
9241
9242 let mut table_writer: ::planus::table_writer::TableWriter<6> =
9243 ::core::default::Default::default();
9244 if prepared_unit.is_some() {
9245 table_writer.write_entry::<self::TimeUnit>(0);
9246 }
9247
9248 unsafe {
9249 table_writer.finish(builder, |object_writer| {
9250 if let ::core::option::Option::Some(prepared_unit) =
9251 prepared_unit
9252 {
9253 object_writer.write::<_, _, 2>(&prepared_unit);
9254 }
9255 });
9256 }
9257 builder.current_offset()
9258 }
9259 }
9260
9261 impl ::planus::WriteAs<::planus::Offset<Duration>> for Duration {
9262 type Prepared = ::planus::Offset<Self>;
9263
9264 #[inline]
9265 fn prepare(
9266 &self,
9267 builder: &mut ::planus::Builder,
9268 ) -> ::planus::Offset<Duration> {
9269 ::planus::WriteAsOffset::prepare(self, builder)
9270 }
9271 }
9272
9273 impl ::planus::WriteAsOptional<::planus::Offset<Duration>> for Duration {
9274 type Prepared = ::planus::Offset<Self>;
9275
9276 #[inline]
9277 fn prepare(
9278 &self,
9279 builder: &mut ::planus::Builder,
9280 ) -> ::core::option::Option<::planus::Offset<Duration>>
9281 {
9282 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
9283 self, builder,
9284 ))
9285 }
9286 }
9287
9288 impl ::planus::WriteAsOffset<Duration> for Duration {
9289 #[inline]
9290 fn prepare(
9291 &self,
9292 builder: &mut ::planus::Builder,
9293 ) -> ::planus::Offset<Duration> {
9294 Duration::create(builder, self.unit)
9295 }
9296 }
9297
9298 /// Builder for serializing an instance of the [Duration] type.
9299 ///
9300 /// Can be created using the [Duration::builder] method.
9301 #[derive(Debug)]
9302 #[must_use]
9303 pub struct DurationBuilder<State>(State);
9304
9305 impl DurationBuilder<()> {
9306 /// Setter for the [`unit` field](Duration#structfield.unit).
9307 #[inline]
9308 #[allow(clippy::type_complexity)]
9309 pub fn unit<T0>(self, value: T0) -> DurationBuilder<(T0,)>
9310 where
9311 T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>,
9312 {
9313 DurationBuilder((value,))
9314 }
9315
9316 /// Sets the [`unit` field](Duration#structfield.unit) to the default value.
9317 #[inline]
9318 #[allow(clippy::type_complexity)]
9319 pub fn unit_as_default(self) -> DurationBuilder<(::planus::DefaultValue,)> {
9320 self.unit(::planus::DefaultValue)
9321 }
9322 }
9323
9324 impl<T0> DurationBuilder<(T0,)> {
9325 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Duration].
9326 #[inline]
9327 pub fn finish(
9328 self,
9329 builder: &mut ::planus::Builder,
9330 ) -> ::planus::Offset<Duration>
9331 where
9332 Self: ::planus::WriteAsOffset<Duration>,
9333 {
9334 ::planus::WriteAsOffset::prepare(&self, builder)
9335 }
9336 }
9337
9338 impl<T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>>
9339 ::planus::WriteAs<::planus::Offset<Duration>> for DurationBuilder<(T0,)>
9340 {
9341 type Prepared = ::planus::Offset<Duration>;
9342
9343 #[inline]
9344 fn prepare(
9345 &self,
9346 builder: &mut ::planus::Builder,
9347 ) -> ::planus::Offset<Duration> {
9348 ::planus::WriteAsOffset::prepare(self, builder)
9349 }
9350 }
9351
9352 impl<T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>>
9353 ::planus::WriteAsOptional<::planus::Offset<Duration>>
9354 for DurationBuilder<(T0,)>
9355 {
9356 type Prepared = ::planus::Offset<Duration>;
9357
9358 #[inline]
9359 fn prepare(
9360 &self,
9361 builder: &mut ::planus::Builder,
9362 ) -> ::core::option::Option<::planus::Offset<Duration>>
9363 {
9364 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
9365 self, builder,
9366 ))
9367 }
9368 }
9369
9370 impl<T0: ::planus::WriteAsDefault<self::TimeUnit, self::TimeUnit>>
9371 ::planus::WriteAsOffset<Duration> for DurationBuilder<(T0,)>
9372 {
9373 #[inline]
9374 fn prepare(
9375 &self,
9376 builder: &mut ::planus::Builder,
9377 ) -> ::planus::Offset<Duration> {
9378 let (v0,) = &self.0;
9379 Duration::create(builder, v0)
9380 }
9381 }
9382
9383 /// Reference to a deserialized [Duration].
9384 #[derive(Copy, Clone)]
9385 pub struct DurationRef<'a>(::planus::table_reader::Table<'a>);
9386
9387 impl<'a> DurationRef<'a> {
9388 /// Getter for the [`unit` field](Duration#structfield.unit).
9389 #[inline]
9390 pub fn unit(&self) -> ::planus::Result<self::TimeUnit> {
9391 ::core::result::Result::Ok(
9392 self.0
9393 .access(0, "Duration", "unit")?
9394 .unwrap_or(self::TimeUnit::Millisecond),
9395 )
9396 }
9397 }
9398
9399 impl<'a> ::core::fmt::Debug for DurationRef<'a> {
9400 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
9401 let mut f = f.debug_struct("DurationRef");
9402 f.field("unit", &self.unit());
9403 f.finish()
9404 }
9405 }
9406
9407 impl<'a> ::core::convert::TryFrom<DurationRef<'a>> for Duration {
9408 type Error = ::planus::Error;
9409
9410 #[allow(unreachable_code)]
9411 fn try_from(value: DurationRef<'a>) -> ::planus::Result<Self> {
9412 ::core::result::Result::Ok(Self {
9413 unit: ::core::convert::TryInto::try_into(value.unit()?)?,
9414 })
9415 }
9416 }
9417
9418 impl<'a> ::planus::TableRead<'a> for DurationRef<'a> {
9419 #[inline]
9420 fn from_buffer(
9421 buffer: ::planus::SliceWithStartOffset<'a>,
9422 offset: usize,
9423 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
9424 {
9425 ::core::result::Result::Ok(Self(
9426 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
9427 ))
9428 }
9429 }
9430
9431 impl<'a> ::planus::VectorReadInner<'a> for DurationRef<'a> {
9432 type Error = ::planus::Error;
9433 const STRIDE: usize = 4;
9434
9435 unsafe fn from_buffer(
9436 buffer: ::planus::SliceWithStartOffset<'a>,
9437 offset: usize,
9438 ) -> ::planus::Result<Self> {
9439 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
9440 error_kind.with_error_location(
9441 "[DurationRef]",
9442 "get",
9443 buffer.offset_from_start,
9444 )
9445 })
9446 }
9447 }
9448
9449 /// # Safety
9450 /// The planus compiler generates implementations that initialize
9451 /// the bytes in `write_values`.
9452 unsafe impl ::planus::VectorWrite<::planus::Offset<Duration>> for Duration {
9453 type Value = ::planus::Offset<Duration>;
9454 const STRIDE: usize = 4;
9455 #[inline]
9456 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
9457 ::planus::WriteAs::prepare(self, builder)
9458 }
9459
9460 #[inline]
9461 unsafe fn write_values(
9462 values: &[::planus::Offset<Duration>],
9463 bytes: *mut ::core::mem::MaybeUninit<u8>,
9464 buffer_position: u32,
9465 ) {
9466 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
9467 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
9468 ::planus::WriteAsPrimitive::write(
9469 v,
9470 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
9471 buffer_position - (Self::STRIDE * i) as u32,
9472 );
9473 }
9474 }
9475 }
9476
9477 impl<'a> ::planus::ReadAsRoot<'a> for DurationRef<'a> {
9478 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
9479 ::planus::TableRead::from_buffer(
9480 ::planus::SliceWithStartOffset {
9481 buffer: slice,
9482 offset_from_start: 0,
9483 },
9484 0,
9485 )
9486 .map_err(|error_kind| {
9487 error_kind.with_error_location("[DurationRef]", "read_as_root", 0)
9488 })
9489 }
9490 }
9491
9492 /// ----------------------------------------------------------------------
9493 /// Top-level Type value, enabling extensible type-specific metadata. We can
9494 /// add new logical types to Type without breaking backwards compatibility
9495 ///
9496 /// Generated from these locations:
9497 /// * Union `Type` in the file `Schema.fbs:442`
9498 #[derive(
9499 Clone,
9500 Debug,
9501 PartialEq,
9502 PartialOrd,
9503 Eq,
9504 Ord,
9505 Hash,
9506 ::serde::Serialize,
9507 ::serde::Deserialize,
9508 )]
9509 pub enum Type {
9510 /// The variant of type `Null` in the union `Type`
9511 Null(::planus::alloc::boxed::Box<self::Null>),
9512
9513 /// The variant of type `Int` in the union `Type`
9514 Int(::planus::alloc::boxed::Box<self::Int>),
9515
9516 /// The variant of type `FloatingPoint` in the union `Type`
9517 FloatingPoint(::planus::alloc::boxed::Box<self::FloatingPoint>),
9518
9519 /// The variant of type `Binary` in the union `Type`
9520 Binary(::planus::alloc::boxed::Box<self::Binary>),
9521
9522 /// The variant of type `Utf8` in the union `Type`
9523 Utf8(::planus::alloc::boxed::Box<self::Utf8>),
9524
9525 /// The variant of type `Bool` in the union `Type`
9526 Bool(::planus::alloc::boxed::Box<self::Bool>),
9527
9528 /// The variant of type `Decimal` in the union `Type`
9529 Decimal(::planus::alloc::boxed::Box<self::Decimal>),
9530
9531 /// The variant of type `Date` in the union `Type`
9532 Date(::planus::alloc::boxed::Box<self::Date>),
9533
9534 /// The variant of type `Time` in the union `Type`
9535 Time(::planus::alloc::boxed::Box<self::Time>),
9536
9537 /// The variant of type `Timestamp` in the union `Type`
9538 Timestamp(::planus::alloc::boxed::Box<self::Timestamp>),
9539
9540 /// The variant of type `Interval` in the union `Type`
9541 Interval(::planus::alloc::boxed::Box<self::Interval>),
9542
9543 /// The variant of type `List` in the union `Type`
9544 List(::planus::alloc::boxed::Box<self::List>),
9545
9546 /// The variant of type `Struct_` in the union `Type`
9547 Struct(::planus::alloc::boxed::Box<self::Struct>),
9548
9549 /// The variant of type `Union` in the union `Type`
9550 Union(::planus::alloc::boxed::Box<self::Union>),
9551
9552 /// The variant of type `FixedSizeBinary` in the union `Type`
9553 FixedSizeBinary(::planus::alloc::boxed::Box<self::FixedSizeBinary>),
9554
9555 /// The variant of type `FixedSizeList` in the union `Type`
9556 FixedSizeList(::planus::alloc::boxed::Box<self::FixedSizeList>),
9557
9558 /// The variant of type `Map` in the union `Type`
9559 Map(::planus::alloc::boxed::Box<self::Map>),
9560
9561 /// The variant of type `Duration` in the union `Type`
9562 Duration(::planus::alloc::boxed::Box<self::Duration>),
9563
9564 /// The variant of type `LargeBinary` in the union `Type`
9565 LargeBinary(::planus::alloc::boxed::Box<self::LargeBinary>),
9566
9567 /// The variant of type `LargeUtf8` in the union `Type`
9568 LargeUtf8(::planus::alloc::boxed::Box<self::LargeUtf8>),
9569
9570 /// The variant of type `LargeList` in the union `Type`
9571 LargeList(::planus::alloc::boxed::Box<self::LargeList>),
9572
9573 /// The variant of type `RunEndEncoded` in the union `Type`
9574 RunEndEncoded(::planus::alloc::boxed::Box<self::RunEndEncoded>),
9575
9576 /// The variant of type `BinaryView` in the union `Type`
9577 BinaryView(::planus::alloc::boxed::Box<self::BinaryView>),
9578
9579 /// The variant of type `Utf8View` in the union `Type`
9580 Utf8View(::planus::alloc::boxed::Box<self::Utf8View>),
9581
9582 /// The variant of type `ListView` in the union `Type`
9583 ListView(::planus::alloc::boxed::Box<self::ListView>),
9584
9585 /// The variant of type `LargeListView` in the union `Type`
9586 LargeListView(::planus::alloc::boxed::Box<self::LargeListView>),
9587 }
9588
9589 impl Type {
9590 /// Creates a [TypeBuilder] for serializing an instance of this table.
9591 #[inline]
9592 pub fn builder() -> TypeBuilder<::planus::Uninitialized> {
9593 TypeBuilder(::planus::Uninitialized)
9594 }
9595
9596 #[inline]
9597 pub fn create_null(
9598 builder: &mut ::planus::Builder,
9599 value: impl ::planus::WriteAsOffset<self::Null>,
9600 ) -> ::planus::UnionOffset<Self> {
9601 ::planus::UnionOffset::new(1, value.prepare(builder).downcast())
9602 }
9603
9604 #[inline]
9605 pub fn create_int(
9606 builder: &mut ::planus::Builder,
9607 value: impl ::planus::WriteAsOffset<self::Int>,
9608 ) -> ::planus::UnionOffset<Self> {
9609 ::planus::UnionOffset::new(2, value.prepare(builder).downcast())
9610 }
9611
9612 #[inline]
9613 pub fn create_floating_point(
9614 builder: &mut ::planus::Builder,
9615 value: impl ::planus::WriteAsOffset<self::FloatingPoint>,
9616 ) -> ::planus::UnionOffset<Self> {
9617 ::planus::UnionOffset::new(3, value.prepare(builder).downcast())
9618 }
9619
9620 #[inline]
9621 pub fn create_binary(
9622 builder: &mut ::planus::Builder,
9623 value: impl ::planus::WriteAsOffset<self::Binary>,
9624 ) -> ::planus::UnionOffset<Self> {
9625 ::planus::UnionOffset::new(4, value.prepare(builder).downcast())
9626 }
9627
9628 #[inline]
9629 pub fn create_utf8(
9630 builder: &mut ::planus::Builder,
9631 value: impl ::planus::WriteAsOffset<self::Utf8>,
9632 ) -> ::planus::UnionOffset<Self> {
9633 ::planus::UnionOffset::new(5, value.prepare(builder).downcast())
9634 }
9635
9636 #[inline]
9637 pub fn create_bool(
9638 builder: &mut ::planus::Builder,
9639 value: impl ::planus::WriteAsOffset<self::Bool>,
9640 ) -> ::planus::UnionOffset<Self> {
9641 ::planus::UnionOffset::new(6, value.prepare(builder).downcast())
9642 }
9643
9644 #[inline]
9645 pub fn create_decimal(
9646 builder: &mut ::planus::Builder,
9647 value: impl ::planus::WriteAsOffset<self::Decimal>,
9648 ) -> ::planus::UnionOffset<Self> {
9649 ::planus::UnionOffset::new(7, value.prepare(builder).downcast())
9650 }
9651
9652 #[inline]
9653 pub fn create_date(
9654 builder: &mut ::planus::Builder,
9655 value: impl ::planus::WriteAsOffset<self::Date>,
9656 ) -> ::planus::UnionOffset<Self> {
9657 ::planus::UnionOffset::new(8, value.prepare(builder).downcast())
9658 }
9659
9660 #[inline]
9661 pub fn create_time(
9662 builder: &mut ::planus::Builder,
9663 value: impl ::planus::WriteAsOffset<self::Time>,
9664 ) -> ::planus::UnionOffset<Self> {
9665 ::planus::UnionOffset::new(9, value.prepare(builder).downcast())
9666 }
9667
9668 #[inline]
9669 pub fn create_timestamp(
9670 builder: &mut ::planus::Builder,
9671 value: impl ::planus::WriteAsOffset<self::Timestamp>,
9672 ) -> ::planus::UnionOffset<Self> {
9673 ::planus::UnionOffset::new(10, value.prepare(builder).downcast())
9674 }
9675
9676 #[inline]
9677 pub fn create_interval(
9678 builder: &mut ::planus::Builder,
9679 value: impl ::planus::WriteAsOffset<self::Interval>,
9680 ) -> ::planus::UnionOffset<Self> {
9681 ::planus::UnionOffset::new(11, value.prepare(builder).downcast())
9682 }
9683
9684 #[inline]
9685 pub fn create_list(
9686 builder: &mut ::planus::Builder,
9687 value: impl ::planus::WriteAsOffset<self::List>,
9688 ) -> ::planus::UnionOffset<Self> {
9689 ::planus::UnionOffset::new(12, value.prepare(builder).downcast())
9690 }
9691
9692 #[inline]
9693 pub fn create_struct(
9694 builder: &mut ::planus::Builder,
9695 value: impl ::planus::WriteAsOffset<self::Struct>,
9696 ) -> ::planus::UnionOffset<Self> {
9697 ::planus::UnionOffset::new(13, value.prepare(builder).downcast())
9698 }
9699
9700 #[inline]
9701 pub fn create_union(
9702 builder: &mut ::planus::Builder,
9703 value: impl ::planus::WriteAsOffset<self::Union>,
9704 ) -> ::planus::UnionOffset<Self> {
9705 ::planus::UnionOffset::new(14, value.prepare(builder).downcast())
9706 }
9707
9708 #[inline]
9709 pub fn create_fixed_size_binary(
9710 builder: &mut ::planus::Builder,
9711 value: impl ::planus::WriteAsOffset<self::FixedSizeBinary>,
9712 ) -> ::planus::UnionOffset<Self> {
9713 ::planus::UnionOffset::new(15, value.prepare(builder).downcast())
9714 }
9715
9716 #[inline]
9717 pub fn create_fixed_size_list(
9718 builder: &mut ::planus::Builder,
9719 value: impl ::planus::WriteAsOffset<self::FixedSizeList>,
9720 ) -> ::planus::UnionOffset<Self> {
9721 ::planus::UnionOffset::new(16, value.prepare(builder).downcast())
9722 }
9723
9724 #[inline]
9725 pub fn create_map(
9726 builder: &mut ::planus::Builder,
9727 value: impl ::planus::WriteAsOffset<self::Map>,
9728 ) -> ::planus::UnionOffset<Self> {
9729 ::planus::UnionOffset::new(17, value.prepare(builder).downcast())
9730 }
9731
9732 #[inline]
9733 pub fn create_duration(
9734 builder: &mut ::planus::Builder,
9735 value: impl ::planus::WriteAsOffset<self::Duration>,
9736 ) -> ::planus::UnionOffset<Self> {
9737 ::planus::UnionOffset::new(18, value.prepare(builder).downcast())
9738 }
9739
9740 #[inline]
9741 pub fn create_large_binary(
9742 builder: &mut ::planus::Builder,
9743 value: impl ::planus::WriteAsOffset<self::LargeBinary>,
9744 ) -> ::planus::UnionOffset<Self> {
9745 ::planus::UnionOffset::new(19, value.prepare(builder).downcast())
9746 }
9747
9748 #[inline]
9749 pub fn create_large_utf8(
9750 builder: &mut ::planus::Builder,
9751 value: impl ::planus::WriteAsOffset<self::LargeUtf8>,
9752 ) -> ::planus::UnionOffset<Self> {
9753 ::planus::UnionOffset::new(20, value.prepare(builder).downcast())
9754 }
9755
9756 #[inline]
9757 pub fn create_large_list(
9758 builder: &mut ::planus::Builder,
9759 value: impl ::planus::WriteAsOffset<self::LargeList>,
9760 ) -> ::planus::UnionOffset<Self> {
9761 ::planus::UnionOffset::new(21, value.prepare(builder).downcast())
9762 }
9763
9764 #[inline]
9765 pub fn create_run_end_encoded(
9766 builder: &mut ::planus::Builder,
9767 value: impl ::planus::WriteAsOffset<self::RunEndEncoded>,
9768 ) -> ::planus::UnionOffset<Self> {
9769 ::planus::UnionOffset::new(22, value.prepare(builder).downcast())
9770 }
9771
9772 #[inline]
9773 pub fn create_binary_view(
9774 builder: &mut ::planus::Builder,
9775 value: impl ::planus::WriteAsOffset<self::BinaryView>,
9776 ) -> ::planus::UnionOffset<Self> {
9777 ::planus::UnionOffset::new(23, value.prepare(builder).downcast())
9778 }
9779
9780 #[inline]
9781 pub fn create_utf8_view(
9782 builder: &mut ::planus::Builder,
9783 value: impl ::planus::WriteAsOffset<self::Utf8View>,
9784 ) -> ::planus::UnionOffset<Self> {
9785 ::planus::UnionOffset::new(24, value.prepare(builder).downcast())
9786 }
9787
9788 #[inline]
9789 pub fn create_list_view(
9790 builder: &mut ::planus::Builder,
9791 value: impl ::planus::WriteAsOffset<self::ListView>,
9792 ) -> ::planus::UnionOffset<Self> {
9793 ::planus::UnionOffset::new(25, value.prepare(builder).downcast())
9794 }
9795
9796 #[inline]
9797 pub fn create_large_list_view(
9798 builder: &mut ::planus::Builder,
9799 value: impl ::planus::WriteAsOffset<self::LargeListView>,
9800 ) -> ::planus::UnionOffset<Self> {
9801 ::planus::UnionOffset::new(26, value.prepare(builder).downcast())
9802 }
9803 }
9804
9805 impl ::planus::WriteAsUnion<Type> for Type {
9806 #[inline]
9807 fn prepare(
9808 &self,
9809 builder: &mut ::planus::Builder,
9810 ) -> ::planus::UnionOffset<Self> {
9811 match self {
9812 Self::Null(value) => Self::create_null(builder, value),
9813 Self::Int(value) => Self::create_int(builder, value),
9814 Self::FloatingPoint(value) => {
9815 Self::create_floating_point(builder, value)
9816 }
9817 Self::Binary(value) => Self::create_binary(builder, value),
9818 Self::Utf8(value) => Self::create_utf8(builder, value),
9819 Self::Bool(value) => Self::create_bool(builder, value),
9820 Self::Decimal(value) => Self::create_decimal(builder, value),
9821 Self::Date(value) => Self::create_date(builder, value),
9822 Self::Time(value) => Self::create_time(builder, value),
9823 Self::Timestamp(value) => Self::create_timestamp(builder, value),
9824 Self::Interval(value) => Self::create_interval(builder, value),
9825 Self::List(value) => Self::create_list(builder, value),
9826 Self::Struct(value) => Self::create_struct(builder, value),
9827 Self::Union(value) => Self::create_union(builder, value),
9828 Self::FixedSizeBinary(value) => {
9829 Self::create_fixed_size_binary(builder, value)
9830 }
9831 Self::FixedSizeList(value) => {
9832 Self::create_fixed_size_list(builder, value)
9833 }
9834 Self::Map(value) => Self::create_map(builder, value),
9835 Self::Duration(value) => Self::create_duration(builder, value),
9836 Self::LargeBinary(value) => {
9837 Self::create_large_binary(builder, value)
9838 }
9839 Self::LargeUtf8(value) => Self::create_large_utf8(builder, value),
9840 Self::LargeList(value) => Self::create_large_list(builder, value),
9841 Self::RunEndEncoded(value) => {
9842 Self::create_run_end_encoded(builder, value)
9843 }
9844 Self::BinaryView(value) => Self::create_binary_view(builder, value),
9845 Self::Utf8View(value) => Self::create_utf8_view(builder, value),
9846 Self::ListView(value) => Self::create_list_view(builder, value),
9847 Self::LargeListView(value) => {
9848 Self::create_large_list_view(builder, value)
9849 }
9850 }
9851 }
9852 }
9853
9854 impl ::planus::WriteAsOptionalUnion<Type> for Type {
9855 #[inline]
9856 fn prepare(
9857 &self,
9858 builder: &mut ::planus::Builder,
9859 ) -> ::core::option::Option<::planus::UnionOffset<Self>>
9860 {
9861 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
9862 self, builder,
9863 ))
9864 }
9865 }
9866
9867 /// Builder for serializing an instance of the [Type] type.
9868 ///
9869 /// Can be created using the [Type::builder] method.
9870 #[derive(Debug)]
9871 #[must_use]
9872 pub struct TypeBuilder<T>(T);
9873
9874 impl TypeBuilder<::planus::Uninitialized> {
9875 /// Creates an instance of the [`Null` variant](Type#variant.Null).
9876 #[inline]
9877 pub fn null<T>(self, value: T) -> TypeBuilder<::planus::Initialized<1, T>>
9878 where
9879 T: ::planus::WriteAsOffset<self::Null>,
9880 {
9881 TypeBuilder(::planus::Initialized(value))
9882 }
9883
9884 /// Creates an instance of the [`Int` variant](Type#variant.Int).
9885 #[inline]
9886 pub fn int<T>(self, value: T) -> TypeBuilder<::planus::Initialized<2, T>>
9887 where
9888 T: ::planus::WriteAsOffset<self::Int>,
9889 {
9890 TypeBuilder(::planus::Initialized(value))
9891 }
9892
9893 /// Creates an instance of the [`FloatingPoint` variant](Type#variant.FloatingPoint).
9894 #[inline]
9895 pub fn floating_point<T>(
9896 self,
9897 value: T,
9898 ) -> TypeBuilder<::planus::Initialized<3, T>>
9899 where
9900 T: ::planus::WriteAsOffset<self::FloatingPoint>,
9901 {
9902 TypeBuilder(::planus::Initialized(value))
9903 }
9904
9905 /// Creates an instance of the [`Binary` variant](Type#variant.Binary).
9906 #[inline]
9907 pub fn binary<T>(self, value: T) -> TypeBuilder<::planus::Initialized<4, T>>
9908 where
9909 T: ::planus::WriteAsOffset<self::Binary>,
9910 {
9911 TypeBuilder(::planus::Initialized(value))
9912 }
9913
9914 /// Creates an instance of the [`Utf8` variant](Type#variant.Utf8).
9915 #[inline]
9916 pub fn utf8<T>(self, value: T) -> TypeBuilder<::planus::Initialized<5, T>>
9917 where
9918 T: ::planus::WriteAsOffset<self::Utf8>,
9919 {
9920 TypeBuilder(::planus::Initialized(value))
9921 }
9922
9923 /// Creates an instance of the [`Bool` variant](Type#variant.Bool).
9924 #[inline]
9925 pub fn bool<T>(self, value: T) -> TypeBuilder<::planus::Initialized<6, T>>
9926 where
9927 T: ::planus::WriteAsOffset<self::Bool>,
9928 {
9929 TypeBuilder(::planus::Initialized(value))
9930 }
9931
9932 /// Creates an instance of the [`Decimal` variant](Type#variant.Decimal).
9933 #[inline]
9934 pub fn decimal<T>(
9935 self,
9936 value: T,
9937 ) -> TypeBuilder<::planus::Initialized<7, T>>
9938 where
9939 T: ::planus::WriteAsOffset<self::Decimal>,
9940 {
9941 TypeBuilder(::planus::Initialized(value))
9942 }
9943
9944 /// Creates an instance of the [`Date` variant](Type#variant.Date).
9945 #[inline]
9946 pub fn date<T>(self, value: T) -> TypeBuilder<::planus::Initialized<8, T>>
9947 where
9948 T: ::planus::WriteAsOffset<self::Date>,
9949 {
9950 TypeBuilder(::planus::Initialized(value))
9951 }
9952
9953 /// Creates an instance of the [`Time` variant](Type#variant.Time).
9954 #[inline]
9955 pub fn time<T>(self, value: T) -> TypeBuilder<::planus::Initialized<9, T>>
9956 where
9957 T: ::planus::WriteAsOffset<self::Time>,
9958 {
9959 TypeBuilder(::planus::Initialized(value))
9960 }
9961
9962 /// Creates an instance of the [`Timestamp` variant](Type#variant.Timestamp).
9963 #[inline]
9964 pub fn timestamp<T>(
9965 self,
9966 value: T,
9967 ) -> TypeBuilder<::planus::Initialized<10, T>>
9968 where
9969 T: ::planus::WriteAsOffset<self::Timestamp>,
9970 {
9971 TypeBuilder(::planus::Initialized(value))
9972 }
9973
9974 /// Creates an instance of the [`Interval` variant](Type#variant.Interval).
9975 #[inline]
9976 pub fn interval<T>(
9977 self,
9978 value: T,
9979 ) -> TypeBuilder<::planus::Initialized<11, T>>
9980 where
9981 T: ::planus::WriteAsOffset<self::Interval>,
9982 {
9983 TypeBuilder(::planus::Initialized(value))
9984 }
9985
9986 /// Creates an instance of the [`List` variant](Type#variant.List).
9987 #[inline]
9988 pub fn list<T>(self, value: T) -> TypeBuilder<::planus::Initialized<12, T>>
9989 where
9990 T: ::planus::WriteAsOffset<self::List>,
9991 {
9992 TypeBuilder(::planus::Initialized(value))
9993 }
9994
9995 /// Creates an instance of the [`Struct_` variant](Type#variant.Struct).
9996 #[inline]
9997 pub fn struct_<T>(
9998 self,
9999 value: T,
10000 ) -> TypeBuilder<::planus::Initialized<13, T>>
10001 where
10002 T: ::planus::WriteAsOffset<self::Struct>,
10003 {
10004 TypeBuilder(::planus::Initialized(value))
10005 }
10006
10007 /// Creates an instance of the [`Union` variant](Type#variant.Union).
10008 #[inline]
10009 pub fn union_<T>(
10010 self,
10011 value: T,
10012 ) -> TypeBuilder<::planus::Initialized<14, T>>
10013 where
10014 T: ::planus::WriteAsOffset<self::Union>,
10015 {
10016 TypeBuilder(::planus::Initialized(value))
10017 }
10018
10019 /// Creates an instance of the [`FixedSizeBinary` variant](Type#variant.FixedSizeBinary).
10020 #[inline]
10021 pub fn fixed_size_binary<T>(
10022 self,
10023 value: T,
10024 ) -> TypeBuilder<::planus::Initialized<15, T>>
10025 where
10026 T: ::planus::WriteAsOffset<self::FixedSizeBinary>,
10027 {
10028 TypeBuilder(::planus::Initialized(value))
10029 }
10030
10031 /// Creates an instance of the [`FixedSizeList` variant](Type#variant.FixedSizeList).
10032 #[inline]
10033 pub fn fixed_size_list<T>(
10034 self,
10035 value: T,
10036 ) -> TypeBuilder<::planus::Initialized<16, T>>
10037 where
10038 T: ::planus::WriteAsOffset<self::FixedSizeList>,
10039 {
10040 TypeBuilder(::planus::Initialized(value))
10041 }
10042
10043 /// Creates an instance of the [`Map` variant](Type#variant.Map).
10044 #[inline]
10045 pub fn map<T>(self, value: T) -> TypeBuilder<::planus::Initialized<17, T>>
10046 where
10047 T: ::planus::WriteAsOffset<self::Map>,
10048 {
10049 TypeBuilder(::planus::Initialized(value))
10050 }
10051
10052 /// Creates an instance of the [`Duration` variant](Type#variant.Duration).
10053 #[inline]
10054 pub fn duration<T>(
10055 self,
10056 value: T,
10057 ) -> TypeBuilder<::planus::Initialized<18, T>>
10058 where
10059 T: ::planus::WriteAsOffset<self::Duration>,
10060 {
10061 TypeBuilder(::planus::Initialized(value))
10062 }
10063
10064 /// Creates an instance of the [`LargeBinary` variant](Type#variant.LargeBinary).
10065 #[inline]
10066 pub fn large_binary<T>(
10067 self,
10068 value: T,
10069 ) -> TypeBuilder<::planus::Initialized<19, T>>
10070 where
10071 T: ::planus::WriteAsOffset<self::LargeBinary>,
10072 {
10073 TypeBuilder(::planus::Initialized(value))
10074 }
10075
10076 /// Creates an instance of the [`LargeUtf8` variant](Type#variant.LargeUtf8).
10077 #[inline]
10078 pub fn large_utf8<T>(
10079 self,
10080 value: T,
10081 ) -> TypeBuilder<::planus::Initialized<20, T>>
10082 where
10083 T: ::planus::WriteAsOffset<self::LargeUtf8>,
10084 {
10085 TypeBuilder(::planus::Initialized(value))
10086 }
10087
10088 /// Creates an instance of the [`LargeList` variant](Type#variant.LargeList).
10089 #[inline]
10090 pub fn large_list<T>(
10091 self,
10092 value: T,
10093 ) -> TypeBuilder<::planus::Initialized<21, T>>
10094 where
10095 T: ::planus::WriteAsOffset<self::LargeList>,
10096 {
10097 TypeBuilder(::planus::Initialized(value))
10098 }
10099
10100 /// Creates an instance of the [`RunEndEncoded` variant](Type#variant.RunEndEncoded).
10101 #[inline]
10102 pub fn run_end_encoded<T>(
10103 self,
10104 value: T,
10105 ) -> TypeBuilder<::planus::Initialized<22, T>>
10106 where
10107 T: ::planus::WriteAsOffset<self::RunEndEncoded>,
10108 {
10109 TypeBuilder(::planus::Initialized(value))
10110 }
10111
10112 /// Creates an instance of the [`BinaryView` variant](Type#variant.BinaryView).
10113 #[inline]
10114 pub fn binary_view<T>(
10115 self,
10116 value: T,
10117 ) -> TypeBuilder<::planus::Initialized<23, T>>
10118 where
10119 T: ::planus::WriteAsOffset<self::BinaryView>,
10120 {
10121 TypeBuilder(::planus::Initialized(value))
10122 }
10123
10124 /// Creates an instance of the [`Utf8View` variant](Type#variant.Utf8View).
10125 #[inline]
10126 pub fn utf8_view<T>(
10127 self,
10128 value: T,
10129 ) -> TypeBuilder<::planus::Initialized<24, T>>
10130 where
10131 T: ::planus::WriteAsOffset<self::Utf8View>,
10132 {
10133 TypeBuilder(::planus::Initialized(value))
10134 }
10135
10136 /// Creates an instance of the [`ListView` variant](Type#variant.ListView).
10137 #[inline]
10138 pub fn list_view<T>(
10139 self,
10140 value: T,
10141 ) -> TypeBuilder<::planus::Initialized<25, T>>
10142 where
10143 T: ::planus::WriteAsOffset<self::ListView>,
10144 {
10145 TypeBuilder(::planus::Initialized(value))
10146 }
10147
10148 /// Creates an instance of the [`LargeListView` variant](Type#variant.LargeListView).
10149 #[inline]
10150 pub fn large_list_view<T>(
10151 self,
10152 value: T,
10153 ) -> TypeBuilder<::planus::Initialized<26, T>>
10154 where
10155 T: ::planus::WriteAsOffset<self::LargeListView>,
10156 {
10157 TypeBuilder(::planus::Initialized(value))
10158 }
10159 }
10160
10161 impl<const N: u8, T> TypeBuilder<::planus::Initialized<N, T>> {
10162 /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Type].
10163 #[inline]
10164 pub fn finish(
10165 self,
10166 builder: &mut ::planus::Builder,
10167 ) -> ::planus::UnionOffset<Type>
10168 where
10169 Self: ::planus::WriteAsUnion<Type>,
10170 {
10171 ::planus::WriteAsUnion::prepare(&self, builder)
10172 }
10173 }
10174
10175 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<1, T>>
10176 where
10177 T: ::planus::WriteAsOffset<self::Null>,
10178 {
10179 #[inline]
10180 fn prepare(
10181 &self,
10182 builder: &mut ::planus::Builder,
10183 ) -> ::planus::UnionOffset<Type> {
10184 ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast())
10185 }
10186 }
10187
10188 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<1, T>>
10189 where
10190 T: ::planus::WriteAsOffset<self::Null>,
10191 {
10192 #[inline]
10193 fn prepare(
10194 &self,
10195 builder: &mut ::planus::Builder,
10196 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10197 {
10198 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10199 self, builder,
10200 ))
10201 }
10202 }
10203 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<2, T>>
10204 where
10205 T: ::planus::WriteAsOffset<self::Int>,
10206 {
10207 #[inline]
10208 fn prepare(
10209 &self,
10210 builder: &mut ::planus::Builder,
10211 ) -> ::planus::UnionOffset<Type> {
10212 ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast())
10213 }
10214 }
10215
10216 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<2, T>>
10217 where
10218 T: ::planus::WriteAsOffset<self::Int>,
10219 {
10220 #[inline]
10221 fn prepare(
10222 &self,
10223 builder: &mut ::planus::Builder,
10224 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10225 {
10226 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10227 self, builder,
10228 ))
10229 }
10230 }
10231 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<3, T>>
10232 where
10233 T: ::planus::WriteAsOffset<self::FloatingPoint>,
10234 {
10235 #[inline]
10236 fn prepare(
10237 &self,
10238 builder: &mut ::planus::Builder,
10239 ) -> ::planus::UnionOffset<Type> {
10240 ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast())
10241 }
10242 }
10243
10244 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<3, T>>
10245 where
10246 T: ::planus::WriteAsOffset<self::FloatingPoint>,
10247 {
10248 #[inline]
10249 fn prepare(
10250 &self,
10251 builder: &mut ::planus::Builder,
10252 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10253 {
10254 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10255 self, builder,
10256 ))
10257 }
10258 }
10259 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<4, T>>
10260 where
10261 T: ::planus::WriteAsOffset<self::Binary>,
10262 {
10263 #[inline]
10264 fn prepare(
10265 &self,
10266 builder: &mut ::planus::Builder,
10267 ) -> ::planus::UnionOffset<Type> {
10268 ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast())
10269 }
10270 }
10271
10272 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<4, T>>
10273 where
10274 T: ::planus::WriteAsOffset<self::Binary>,
10275 {
10276 #[inline]
10277 fn prepare(
10278 &self,
10279 builder: &mut ::planus::Builder,
10280 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10281 {
10282 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10283 self, builder,
10284 ))
10285 }
10286 }
10287 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<5, T>>
10288 where
10289 T: ::planus::WriteAsOffset<self::Utf8>,
10290 {
10291 #[inline]
10292 fn prepare(
10293 &self,
10294 builder: &mut ::planus::Builder,
10295 ) -> ::planus::UnionOffset<Type> {
10296 ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast())
10297 }
10298 }
10299
10300 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<5, T>>
10301 where
10302 T: ::planus::WriteAsOffset<self::Utf8>,
10303 {
10304 #[inline]
10305 fn prepare(
10306 &self,
10307 builder: &mut ::planus::Builder,
10308 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10309 {
10310 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10311 self, builder,
10312 ))
10313 }
10314 }
10315 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<6, T>>
10316 where
10317 T: ::planus::WriteAsOffset<self::Bool>,
10318 {
10319 #[inline]
10320 fn prepare(
10321 &self,
10322 builder: &mut ::planus::Builder,
10323 ) -> ::planus::UnionOffset<Type> {
10324 ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast())
10325 }
10326 }
10327
10328 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<6, T>>
10329 where
10330 T: ::planus::WriteAsOffset<self::Bool>,
10331 {
10332 #[inline]
10333 fn prepare(
10334 &self,
10335 builder: &mut ::planus::Builder,
10336 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10337 {
10338 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10339 self, builder,
10340 ))
10341 }
10342 }
10343 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<7, T>>
10344 where
10345 T: ::planus::WriteAsOffset<self::Decimal>,
10346 {
10347 #[inline]
10348 fn prepare(
10349 &self,
10350 builder: &mut ::planus::Builder,
10351 ) -> ::planus::UnionOffset<Type> {
10352 ::planus::UnionOffset::new(7, (self.0).0.prepare(builder).downcast())
10353 }
10354 }
10355
10356 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<7, T>>
10357 where
10358 T: ::planus::WriteAsOffset<self::Decimal>,
10359 {
10360 #[inline]
10361 fn prepare(
10362 &self,
10363 builder: &mut ::planus::Builder,
10364 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10365 {
10366 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10367 self, builder,
10368 ))
10369 }
10370 }
10371 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<8, T>>
10372 where
10373 T: ::planus::WriteAsOffset<self::Date>,
10374 {
10375 #[inline]
10376 fn prepare(
10377 &self,
10378 builder: &mut ::planus::Builder,
10379 ) -> ::planus::UnionOffset<Type> {
10380 ::planus::UnionOffset::new(8, (self.0).0.prepare(builder).downcast())
10381 }
10382 }
10383
10384 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<8, T>>
10385 where
10386 T: ::planus::WriteAsOffset<self::Date>,
10387 {
10388 #[inline]
10389 fn prepare(
10390 &self,
10391 builder: &mut ::planus::Builder,
10392 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10393 {
10394 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10395 self, builder,
10396 ))
10397 }
10398 }
10399 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<9, T>>
10400 where
10401 T: ::planus::WriteAsOffset<self::Time>,
10402 {
10403 #[inline]
10404 fn prepare(
10405 &self,
10406 builder: &mut ::planus::Builder,
10407 ) -> ::planus::UnionOffset<Type> {
10408 ::planus::UnionOffset::new(9, (self.0).0.prepare(builder).downcast())
10409 }
10410 }
10411
10412 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<9, T>>
10413 where
10414 T: ::planus::WriteAsOffset<self::Time>,
10415 {
10416 #[inline]
10417 fn prepare(
10418 &self,
10419 builder: &mut ::planus::Builder,
10420 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10421 {
10422 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10423 self, builder,
10424 ))
10425 }
10426 }
10427 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<10, T>>
10428 where
10429 T: ::planus::WriteAsOffset<self::Timestamp>,
10430 {
10431 #[inline]
10432 fn prepare(
10433 &self,
10434 builder: &mut ::planus::Builder,
10435 ) -> ::planus::UnionOffset<Type> {
10436 ::planus::UnionOffset::new(10, (self.0).0.prepare(builder).downcast())
10437 }
10438 }
10439
10440 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<10, T>>
10441 where
10442 T: ::planus::WriteAsOffset<self::Timestamp>,
10443 {
10444 #[inline]
10445 fn prepare(
10446 &self,
10447 builder: &mut ::planus::Builder,
10448 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10449 {
10450 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10451 self, builder,
10452 ))
10453 }
10454 }
10455 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<11, T>>
10456 where
10457 T: ::planus::WriteAsOffset<self::Interval>,
10458 {
10459 #[inline]
10460 fn prepare(
10461 &self,
10462 builder: &mut ::planus::Builder,
10463 ) -> ::planus::UnionOffset<Type> {
10464 ::planus::UnionOffset::new(11, (self.0).0.prepare(builder).downcast())
10465 }
10466 }
10467
10468 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<11, T>>
10469 where
10470 T: ::planus::WriteAsOffset<self::Interval>,
10471 {
10472 #[inline]
10473 fn prepare(
10474 &self,
10475 builder: &mut ::planus::Builder,
10476 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10477 {
10478 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10479 self, builder,
10480 ))
10481 }
10482 }
10483 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<12, T>>
10484 where
10485 T: ::planus::WriteAsOffset<self::List>,
10486 {
10487 #[inline]
10488 fn prepare(
10489 &self,
10490 builder: &mut ::planus::Builder,
10491 ) -> ::planus::UnionOffset<Type> {
10492 ::planus::UnionOffset::new(12, (self.0).0.prepare(builder).downcast())
10493 }
10494 }
10495
10496 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<12, T>>
10497 where
10498 T: ::planus::WriteAsOffset<self::List>,
10499 {
10500 #[inline]
10501 fn prepare(
10502 &self,
10503 builder: &mut ::planus::Builder,
10504 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10505 {
10506 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10507 self, builder,
10508 ))
10509 }
10510 }
10511 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<13, T>>
10512 where
10513 T: ::planus::WriteAsOffset<self::Struct>,
10514 {
10515 #[inline]
10516 fn prepare(
10517 &self,
10518 builder: &mut ::planus::Builder,
10519 ) -> ::planus::UnionOffset<Type> {
10520 ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast())
10521 }
10522 }
10523
10524 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<13, T>>
10525 where
10526 T: ::planus::WriteAsOffset<self::Struct>,
10527 {
10528 #[inline]
10529 fn prepare(
10530 &self,
10531 builder: &mut ::planus::Builder,
10532 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10533 {
10534 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10535 self, builder,
10536 ))
10537 }
10538 }
10539 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<14, T>>
10540 where
10541 T: ::planus::WriteAsOffset<self::Union>,
10542 {
10543 #[inline]
10544 fn prepare(
10545 &self,
10546 builder: &mut ::planus::Builder,
10547 ) -> ::planus::UnionOffset<Type> {
10548 ::planus::UnionOffset::new(14, (self.0).0.prepare(builder).downcast())
10549 }
10550 }
10551
10552 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<14, T>>
10553 where
10554 T: ::planus::WriteAsOffset<self::Union>,
10555 {
10556 #[inline]
10557 fn prepare(
10558 &self,
10559 builder: &mut ::planus::Builder,
10560 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10561 {
10562 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10563 self, builder,
10564 ))
10565 }
10566 }
10567 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<15, T>>
10568 where
10569 T: ::planus::WriteAsOffset<self::FixedSizeBinary>,
10570 {
10571 #[inline]
10572 fn prepare(
10573 &self,
10574 builder: &mut ::planus::Builder,
10575 ) -> ::planus::UnionOffset<Type> {
10576 ::planus::UnionOffset::new(15, (self.0).0.prepare(builder).downcast())
10577 }
10578 }
10579
10580 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<15, T>>
10581 where
10582 T: ::planus::WriteAsOffset<self::FixedSizeBinary>,
10583 {
10584 #[inline]
10585 fn prepare(
10586 &self,
10587 builder: &mut ::planus::Builder,
10588 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10589 {
10590 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10591 self, builder,
10592 ))
10593 }
10594 }
10595 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<16, T>>
10596 where
10597 T: ::planus::WriteAsOffset<self::FixedSizeList>,
10598 {
10599 #[inline]
10600 fn prepare(
10601 &self,
10602 builder: &mut ::planus::Builder,
10603 ) -> ::planus::UnionOffset<Type> {
10604 ::planus::UnionOffset::new(16, (self.0).0.prepare(builder).downcast())
10605 }
10606 }
10607
10608 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<16, T>>
10609 where
10610 T: ::planus::WriteAsOffset<self::FixedSizeList>,
10611 {
10612 #[inline]
10613 fn prepare(
10614 &self,
10615 builder: &mut ::planus::Builder,
10616 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10617 {
10618 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10619 self, builder,
10620 ))
10621 }
10622 }
10623 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<17, T>>
10624 where
10625 T: ::planus::WriteAsOffset<self::Map>,
10626 {
10627 #[inline]
10628 fn prepare(
10629 &self,
10630 builder: &mut ::planus::Builder,
10631 ) -> ::planus::UnionOffset<Type> {
10632 ::planus::UnionOffset::new(17, (self.0).0.prepare(builder).downcast())
10633 }
10634 }
10635
10636 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<17, T>>
10637 where
10638 T: ::planus::WriteAsOffset<self::Map>,
10639 {
10640 #[inline]
10641 fn prepare(
10642 &self,
10643 builder: &mut ::planus::Builder,
10644 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10645 {
10646 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10647 self, builder,
10648 ))
10649 }
10650 }
10651 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<18, T>>
10652 where
10653 T: ::planus::WriteAsOffset<self::Duration>,
10654 {
10655 #[inline]
10656 fn prepare(
10657 &self,
10658 builder: &mut ::planus::Builder,
10659 ) -> ::planus::UnionOffset<Type> {
10660 ::planus::UnionOffset::new(18, (self.0).0.prepare(builder).downcast())
10661 }
10662 }
10663
10664 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<18, T>>
10665 where
10666 T: ::planus::WriteAsOffset<self::Duration>,
10667 {
10668 #[inline]
10669 fn prepare(
10670 &self,
10671 builder: &mut ::planus::Builder,
10672 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10673 {
10674 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10675 self, builder,
10676 ))
10677 }
10678 }
10679 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<19, T>>
10680 where
10681 T: ::planus::WriteAsOffset<self::LargeBinary>,
10682 {
10683 #[inline]
10684 fn prepare(
10685 &self,
10686 builder: &mut ::planus::Builder,
10687 ) -> ::planus::UnionOffset<Type> {
10688 ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast())
10689 }
10690 }
10691
10692 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<19, T>>
10693 where
10694 T: ::planus::WriteAsOffset<self::LargeBinary>,
10695 {
10696 #[inline]
10697 fn prepare(
10698 &self,
10699 builder: &mut ::planus::Builder,
10700 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10701 {
10702 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10703 self, builder,
10704 ))
10705 }
10706 }
10707 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<20, T>>
10708 where
10709 T: ::planus::WriteAsOffset<self::LargeUtf8>,
10710 {
10711 #[inline]
10712 fn prepare(
10713 &self,
10714 builder: &mut ::planus::Builder,
10715 ) -> ::planus::UnionOffset<Type> {
10716 ::planus::UnionOffset::new(20, (self.0).0.prepare(builder).downcast())
10717 }
10718 }
10719
10720 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<20, T>>
10721 where
10722 T: ::planus::WriteAsOffset<self::LargeUtf8>,
10723 {
10724 #[inline]
10725 fn prepare(
10726 &self,
10727 builder: &mut ::planus::Builder,
10728 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10729 {
10730 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10731 self, builder,
10732 ))
10733 }
10734 }
10735 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<21, T>>
10736 where
10737 T: ::planus::WriteAsOffset<self::LargeList>,
10738 {
10739 #[inline]
10740 fn prepare(
10741 &self,
10742 builder: &mut ::planus::Builder,
10743 ) -> ::planus::UnionOffset<Type> {
10744 ::planus::UnionOffset::new(21, (self.0).0.prepare(builder).downcast())
10745 }
10746 }
10747
10748 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<21, T>>
10749 where
10750 T: ::planus::WriteAsOffset<self::LargeList>,
10751 {
10752 #[inline]
10753 fn prepare(
10754 &self,
10755 builder: &mut ::planus::Builder,
10756 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10757 {
10758 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10759 self, builder,
10760 ))
10761 }
10762 }
10763 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<22, T>>
10764 where
10765 T: ::planus::WriteAsOffset<self::RunEndEncoded>,
10766 {
10767 #[inline]
10768 fn prepare(
10769 &self,
10770 builder: &mut ::planus::Builder,
10771 ) -> ::planus::UnionOffset<Type> {
10772 ::planus::UnionOffset::new(22, (self.0).0.prepare(builder).downcast())
10773 }
10774 }
10775
10776 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<22, T>>
10777 where
10778 T: ::planus::WriteAsOffset<self::RunEndEncoded>,
10779 {
10780 #[inline]
10781 fn prepare(
10782 &self,
10783 builder: &mut ::planus::Builder,
10784 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10785 {
10786 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10787 self, builder,
10788 ))
10789 }
10790 }
10791 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<23, T>>
10792 where
10793 T: ::planus::WriteAsOffset<self::BinaryView>,
10794 {
10795 #[inline]
10796 fn prepare(
10797 &self,
10798 builder: &mut ::planus::Builder,
10799 ) -> ::planus::UnionOffset<Type> {
10800 ::planus::UnionOffset::new(23, (self.0).0.prepare(builder).downcast())
10801 }
10802 }
10803
10804 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<23, T>>
10805 where
10806 T: ::planus::WriteAsOffset<self::BinaryView>,
10807 {
10808 #[inline]
10809 fn prepare(
10810 &self,
10811 builder: &mut ::planus::Builder,
10812 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10813 {
10814 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10815 self, builder,
10816 ))
10817 }
10818 }
10819 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<24, T>>
10820 where
10821 T: ::planus::WriteAsOffset<self::Utf8View>,
10822 {
10823 #[inline]
10824 fn prepare(
10825 &self,
10826 builder: &mut ::planus::Builder,
10827 ) -> ::planus::UnionOffset<Type> {
10828 ::planus::UnionOffset::new(24, (self.0).0.prepare(builder).downcast())
10829 }
10830 }
10831
10832 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<24, T>>
10833 where
10834 T: ::planus::WriteAsOffset<self::Utf8View>,
10835 {
10836 #[inline]
10837 fn prepare(
10838 &self,
10839 builder: &mut ::planus::Builder,
10840 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10841 {
10842 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10843 self, builder,
10844 ))
10845 }
10846 }
10847 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<25, T>>
10848 where
10849 T: ::planus::WriteAsOffset<self::ListView>,
10850 {
10851 #[inline]
10852 fn prepare(
10853 &self,
10854 builder: &mut ::planus::Builder,
10855 ) -> ::planus::UnionOffset<Type> {
10856 ::planus::UnionOffset::new(25, (self.0).0.prepare(builder).downcast())
10857 }
10858 }
10859
10860 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<25, T>>
10861 where
10862 T: ::planus::WriteAsOffset<self::ListView>,
10863 {
10864 #[inline]
10865 fn prepare(
10866 &self,
10867 builder: &mut ::planus::Builder,
10868 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10869 {
10870 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10871 self, builder,
10872 ))
10873 }
10874 }
10875 impl<T> ::planus::WriteAsUnion<Type> for TypeBuilder<::planus::Initialized<26, T>>
10876 where
10877 T: ::planus::WriteAsOffset<self::LargeListView>,
10878 {
10879 #[inline]
10880 fn prepare(
10881 &self,
10882 builder: &mut ::planus::Builder,
10883 ) -> ::planus::UnionOffset<Type> {
10884 ::planus::UnionOffset::new(26, (self.0).0.prepare(builder).downcast())
10885 }
10886 }
10887
10888 impl<T> ::planus::WriteAsOptionalUnion<Type> for TypeBuilder<::planus::Initialized<26, T>>
10889 where
10890 T: ::planus::WriteAsOffset<self::LargeListView>,
10891 {
10892 #[inline]
10893 fn prepare(
10894 &self,
10895 builder: &mut ::planus::Builder,
10896 ) -> ::core::option::Option<::planus::UnionOffset<Type>>
10897 {
10898 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
10899 self, builder,
10900 ))
10901 }
10902 }
10903
10904 /// Reference to a deserialized [Type].
10905 #[derive(Copy, Clone, Debug)]
10906 pub enum TypeRef<'a> {
10907 Null(self::NullRef<'a>),
10908 Int(self::IntRef<'a>),
10909 FloatingPoint(self::FloatingPointRef<'a>),
10910 Binary(self::BinaryRef<'a>),
10911 Utf8(self::Utf8Ref<'a>),
10912 Bool(self::BoolRef<'a>),
10913 Decimal(self::DecimalRef<'a>),
10914 Date(self::DateRef<'a>),
10915 Time(self::TimeRef<'a>),
10916 Timestamp(self::TimestampRef<'a>),
10917 Interval(self::IntervalRef<'a>),
10918 List(self::ListRef<'a>),
10919 Struct(self::StructRef<'a>),
10920 Union(self::UnionRef<'a>),
10921 FixedSizeBinary(self::FixedSizeBinaryRef<'a>),
10922 FixedSizeList(self::FixedSizeListRef<'a>),
10923 Map(self::MapRef<'a>),
10924 Duration(self::DurationRef<'a>),
10925 LargeBinary(self::LargeBinaryRef<'a>),
10926 LargeUtf8(self::LargeUtf8Ref<'a>),
10927 LargeList(self::LargeListRef<'a>),
10928 RunEndEncoded(self::RunEndEncodedRef<'a>),
10929 BinaryView(self::BinaryViewRef<'a>),
10930 Utf8View(self::Utf8ViewRef<'a>),
10931 ListView(self::ListViewRef<'a>),
10932 LargeListView(self::LargeListViewRef<'a>),
10933 }
10934
10935 impl<'a> ::core::convert::TryFrom<TypeRef<'a>> for Type {
10936 type Error = ::planus::Error;
10937
10938 fn try_from(value: TypeRef<'a>) -> ::planus::Result<Self> {
10939 ::core::result::Result::Ok(match value {
10940 TypeRef::Null(value) => {
10941 Self::Null(::planus::alloc::boxed::Box::new(
10942 ::core::convert::TryFrom::try_from(value)?,
10943 ))
10944 }
10945
10946 TypeRef::Int(value) => Self::Int(::planus::alloc::boxed::Box::new(
10947 ::core::convert::TryFrom::try_from(value)?,
10948 )),
10949
10950 TypeRef::FloatingPoint(value) => {
10951 Self::FloatingPoint(::planus::alloc::boxed::Box::new(
10952 ::core::convert::TryFrom::try_from(value)?,
10953 ))
10954 }
10955
10956 TypeRef::Binary(value) => {
10957 Self::Binary(::planus::alloc::boxed::Box::new(
10958 ::core::convert::TryFrom::try_from(value)?,
10959 ))
10960 }
10961
10962 TypeRef::Utf8(value) => {
10963 Self::Utf8(::planus::alloc::boxed::Box::new(
10964 ::core::convert::TryFrom::try_from(value)?,
10965 ))
10966 }
10967
10968 TypeRef::Bool(value) => {
10969 Self::Bool(::planus::alloc::boxed::Box::new(
10970 ::core::convert::TryFrom::try_from(value)?,
10971 ))
10972 }
10973
10974 TypeRef::Decimal(value) => {
10975 Self::Decimal(::planus::alloc::boxed::Box::new(
10976 ::core::convert::TryFrom::try_from(value)?,
10977 ))
10978 }
10979
10980 TypeRef::Date(value) => {
10981 Self::Date(::planus::alloc::boxed::Box::new(
10982 ::core::convert::TryFrom::try_from(value)?,
10983 ))
10984 }
10985
10986 TypeRef::Time(value) => {
10987 Self::Time(::planus::alloc::boxed::Box::new(
10988 ::core::convert::TryFrom::try_from(value)?,
10989 ))
10990 }
10991
10992 TypeRef::Timestamp(value) => {
10993 Self::Timestamp(::planus::alloc::boxed::Box::new(
10994 ::core::convert::TryFrom::try_from(value)?,
10995 ))
10996 }
10997
10998 TypeRef::Interval(value) => {
10999 Self::Interval(::planus::alloc::boxed::Box::new(
11000 ::core::convert::TryFrom::try_from(value)?,
11001 ))
11002 }
11003
11004 TypeRef::List(value) => {
11005 Self::List(::planus::alloc::boxed::Box::new(
11006 ::core::convert::TryFrom::try_from(value)?,
11007 ))
11008 }
11009
11010 TypeRef::Struct(value) => {
11011 Self::Struct(::planus::alloc::boxed::Box::new(
11012 ::core::convert::TryFrom::try_from(value)?,
11013 ))
11014 }
11015
11016 TypeRef::Union(value) => {
11017 Self::Union(::planus::alloc::boxed::Box::new(
11018 ::core::convert::TryFrom::try_from(value)?,
11019 ))
11020 }
11021
11022 TypeRef::FixedSizeBinary(value) => {
11023 Self::FixedSizeBinary(::planus::alloc::boxed::Box::new(
11024 ::core::convert::TryFrom::try_from(value)?,
11025 ))
11026 }
11027
11028 TypeRef::FixedSizeList(value) => {
11029 Self::FixedSizeList(::planus::alloc::boxed::Box::new(
11030 ::core::convert::TryFrom::try_from(value)?,
11031 ))
11032 }
11033
11034 TypeRef::Map(value) => Self::Map(::planus::alloc::boxed::Box::new(
11035 ::core::convert::TryFrom::try_from(value)?,
11036 )),
11037
11038 TypeRef::Duration(value) => {
11039 Self::Duration(::planus::alloc::boxed::Box::new(
11040 ::core::convert::TryFrom::try_from(value)?,
11041 ))
11042 }
11043
11044 TypeRef::LargeBinary(value) => {
11045 Self::LargeBinary(::planus::alloc::boxed::Box::new(
11046 ::core::convert::TryFrom::try_from(value)?,
11047 ))
11048 }
11049
11050 TypeRef::LargeUtf8(value) => {
11051 Self::LargeUtf8(::planus::alloc::boxed::Box::new(
11052 ::core::convert::TryFrom::try_from(value)?,
11053 ))
11054 }
11055
11056 TypeRef::LargeList(value) => {
11057 Self::LargeList(::planus::alloc::boxed::Box::new(
11058 ::core::convert::TryFrom::try_from(value)?,
11059 ))
11060 }
11061
11062 TypeRef::RunEndEncoded(value) => {
11063 Self::RunEndEncoded(::planus::alloc::boxed::Box::new(
11064 ::core::convert::TryFrom::try_from(value)?,
11065 ))
11066 }
11067
11068 TypeRef::BinaryView(value) => {
11069 Self::BinaryView(::planus::alloc::boxed::Box::new(
11070 ::core::convert::TryFrom::try_from(value)?,
11071 ))
11072 }
11073
11074 TypeRef::Utf8View(value) => {
11075 Self::Utf8View(::planus::alloc::boxed::Box::new(
11076 ::core::convert::TryFrom::try_from(value)?,
11077 ))
11078 }
11079
11080 TypeRef::ListView(value) => {
11081 Self::ListView(::planus::alloc::boxed::Box::new(
11082 ::core::convert::TryFrom::try_from(value)?,
11083 ))
11084 }
11085
11086 TypeRef::LargeListView(value) => {
11087 Self::LargeListView(::planus::alloc::boxed::Box::new(
11088 ::core::convert::TryFrom::try_from(value)?,
11089 ))
11090 }
11091 })
11092 }
11093 }
11094
11095 impl<'a> ::planus::TableReadUnion<'a> for TypeRef<'a> {
11096 fn from_buffer(
11097 buffer: ::planus::SliceWithStartOffset<'a>,
11098 tag: u8,
11099 field_offset: usize,
11100 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
11101 {
11102 match tag {
11103 1 => ::core::result::Result::Ok(Self::Null(
11104 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11105 )),
11106 2 => ::core::result::Result::Ok(Self::Int(
11107 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11108 )),
11109 3 => ::core::result::Result::Ok(Self::FloatingPoint(
11110 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11111 )),
11112 4 => ::core::result::Result::Ok(Self::Binary(
11113 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11114 )),
11115 5 => ::core::result::Result::Ok(Self::Utf8(
11116 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11117 )),
11118 6 => ::core::result::Result::Ok(Self::Bool(
11119 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11120 )),
11121 7 => ::core::result::Result::Ok(Self::Decimal(
11122 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11123 )),
11124 8 => ::core::result::Result::Ok(Self::Date(
11125 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11126 )),
11127 9 => ::core::result::Result::Ok(Self::Time(
11128 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11129 )),
11130 10 => ::core::result::Result::Ok(Self::Timestamp(
11131 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11132 )),
11133 11 => ::core::result::Result::Ok(Self::Interval(
11134 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11135 )),
11136 12 => ::core::result::Result::Ok(Self::List(
11137 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11138 )),
11139 13 => ::core::result::Result::Ok(Self::Struct(
11140 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11141 )),
11142 14 => ::core::result::Result::Ok(Self::Union(
11143 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11144 )),
11145 15 => ::core::result::Result::Ok(Self::FixedSizeBinary(
11146 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11147 )),
11148 16 => ::core::result::Result::Ok(Self::FixedSizeList(
11149 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11150 )),
11151 17 => ::core::result::Result::Ok(Self::Map(
11152 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11153 )),
11154 18 => ::core::result::Result::Ok(Self::Duration(
11155 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11156 )),
11157 19 => ::core::result::Result::Ok(Self::LargeBinary(
11158 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11159 )),
11160 20 => ::core::result::Result::Ok(Self::LargeUtf8(
11161 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11162 )),
11163 21 => ::core::result::Result::Ok(Self::LargeList(
11164 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11165 )),
11166 22 => ::core::result::Result::Ok(Self::RunEndEncoded(
11167 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11168 )),
11169 23 => ::core::result::Result::Ok(Self::BinaryView(
11170 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11171 )),
11172 24 => ::core::result::Result::Ok(Self::Utf8View(
11173 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11174 )),
11175 25 => ::core::result::Result::Ok(Self::ListView(
11176 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11177 )),
11178 26 => ::core::result::Result::Ok(Self::LargeListView(
11179 ::planus::TableRead::from_buffer(buffer, field_offset)?,
11180 )),
11181 _ => ::core::result::Result::Err(
11182 ::planus::errors::ErrorKind::UnknownUnionTag { tag },
11183 ),
11184 }
11185 }
11186 }
11187
11188 impl<'a> ::planus::VectorReadUnion<'a> for TypeRef<'a> {
11189 const VECTOR_NAME: &'static str = "[TypeRef]";
11190 }
11191
11192 /// ----------------------------------------------------------------------
11193 /// user defined key value pairs to add custom metadata to arrow
11194 /// key namespacing is the responsibility of the user
11195 ///
11196 /// Generated from these locations:
11197 /// * Table `KeyValue` in the file `Schema.fbs:475`
11198 #[derive(
11199 Clone,
11200 Debug,
11201 PartialEq,
11202 PartialOrd,
11203 Eq,
11204 Ord,
11205 Hash,
11206 ::serde::Serialize,
11207 ::serde::Deserialize,
11208 )]
11209 pub struct KeyValue {
11210 /// The field `key` in the table `KeyValue`
11211 pub key: ::core::option::Option<::planus::alloc::string::String>,
11212 /// The field `value` in the table `KeyValue`
11213 pub value: ::core::option::Option<::planus::alloc::string::String>,
11214 }
11215
11216 #[allow(clippy::derivable_impls)]
11217 impl ::core::default::Default for KeyValue {
11218 fn default() -> Self {
11219 Self {
11220 key: ::core::default::Default::default(),
11221 value: ::core::default::Default::default(),
11222 }
11223 }
11224 }
11225
11226 impl KeyValue {
11227 /// Creates a [KeyValueBuilder] for serializing an instance of this table.
11228 #[inline]
11229 pub fn builder() -> KeyValueBuilder<()> {
11230 KeyValueBuilder(())
11231 }
11232
11233 #[allow(clippy::too_many_arguments)]
11234 pub fn create(
11235 builder: &mut ::planus::Builder,
11236 field_key: impl ::planus::WriteAsOptional<
11237 ::planus::Offset<::core::primitive::str>,
11238 >,
11239 field_value: impl ::planus::WriteAsOptional<
11240 ::planus::Offset<::core::primitive::str>,
11241 >,
11242 ) -> ::planus::Offset<Self> {
11243 let prepared_key = field_key.prepare(builder);
11244 let prepared_value = field_value.prepare(builder);
11245
11246 let mut table_writer: ::planus::table_writer::TableWriter<8> =
11247 ::core::default::Default::default();
11248 if prepared_key.is_some() {
11249 table_writer.write_entry::<::planus::Offset<str>>(0);
11250 }
11251 if prepared_value.is_some() {
11252 table_writer.write_entry::<::planus::Offset<str>>(1);
11253 }
11254
11255 unsafe {
11256 table_writer.finish(builder, |object_writer| {
11257 if let ::core::option::Option::Some(prepared_key) = prepared_key
11258 {
11259 object_writer.write::<_, _, 4>(&prepared_key);
11260 }
11261 if let ::core::option::Option::Some(prepared_value) =
11262 prepared_value
11263 {
11264 object_writer.write::<_, _, 4>(&prepared_value);
11265 }
11266 });
11267 }
11268 builder.current_offset()
11269 }
11270 }
11271
11272 impl ::planus::WriteAs<::planus::Offset<KeyValue>> for KeyValue {
11273 type Prepared = ::planus::Offset<Self>;
11274
11275 #[inline]
11276 fn prepare(
11277 &self,
11278 builder: &mut ::planus::Builder,
11279 ) -> ::planus::Offset<KeyValue> {
11280 ::planus::WriteAsOffset::prepare(self, builder)
11281 }
11282 }
11283
11284 impl ::planus::WriteAsOptional<::planus::Offset<KeyValue>> for KeyValue {
11285 type Prepared = ::planus::Offset<Self>;
11286
11287 #[inline]
11288 fn prepare(
11289 &self,
11290 builder: &mut ::planus::Builder,
11291 ) -> ::core::option::Option<::planus::Offset<KeyValue>>
11292 {
11293 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
11294 self, builder,
11295 ))
11296 }
11297 }
11298
11299 impl ::planus::WriteAsOffset<KeyValue> for KeyValue {
11300 #[inline]
11301 fn prepare(
11302 &self,
11303 builder: &mut ::planus::Builder,
11304 ) -> ::planus::Offset<KeyValue> {
11305 KeyValue::create(builder, &self.key, &self.value)
11306 }
11307 }
11308
11309 /// Builder for serializing an instance of the [KeyValue] type.
11310 ///
11311 /// Can be created using the [KeyValue::builder] method.
11312 #[derive(Debug)]
11313 #[must_use]
11314 pub struct KeyValueBuilder<State>(State);
11315
11316 impl KeyValueBuilder<()> {
11317 /// Setter for the [`key` field](KeyValue#structfield.key).
11318 #[inline]
11319 #[allow(clippy::type_complexity)]
11320 pub fn key<T0>(self, value: T0) -> KeyValueBuilder<(T0,)>
11321 where
11322 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11323 {
11324 KeyValueBuilder((value,))
11325 }
11326
11327 /// Sets the [`key` field](KeyValue#structfield.key) to null.
11328 #[inline]
11329 #[allow(clippy::type_complexity)]
11330 pub fn key_as_null(self) -> KeyValueBuilder<((),)> {
11331 self.key(())
11332 }
11333 }
11334
11335 impl<T0> KeyValueBuilder<(T0,)> {
11336 /// Setter for the [`value` field](KeyValue#structfield.value).
11337 #[inline]
11338 #[allow(clippy::type_complexity)]
11339 pub fn value<T1>(self, value: T1) -> KeyValueBuilder<(T0, T1)>
11340 where
11341 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11342 {
11343 let (v0,) = self.0;
11344 KeyValueBuilder((v0, value))
11345 }
11346
11347 /// Sets the [`value` field](KeyValue#structfield.value) to null.
11348 #[inline]
11349 #[allow(clippy::type_complexity)]
11350 pub fn value_as_null(self) -> KeyValueBuilder<(T0, ())> {
11351 self.value(())
11352 }
11353 }
11354
11355 impl<T0, T1> KeyValueBuilder<(T0, T1)> {
11356 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [KeyValue].
11357 #[inline]
11358 pub fn finish(
11359 self,
11360 builder: &mut ::planus::Builder,
11361 ) -> ::planus::Offset<KeyValue>
11362 where
11363 Self: ::planus::WriteAsOffset<KeyValue>,
11364 {
11365 ::planus::WriteAsOffset::prepare(&self, builder)
11366 }
11367 }
11368
11369 impl<
11370 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11371 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11372 > ::planus::WriteAs<::planus::Offset<KeyValue>>
11373 for KeyValueBuilder<(T0, T1)>
11374 {
11375 type Prepared = ::planus::Offset<KeyValue>;
11376
11377 #[inline]
11378 fn prepare(
11379 &self,
11380 builder: &mut ::planus::Builder,
11381 ) -> ::planus::Offset<KeyValue> {
11382 ::planus::WriteAsOffset::prepare(self, builder)
11383 }
11384 }
11385
11386 impl<
11387 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11388 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11389 > ::planus::WriteAsOptional<::planus::Offset<KeyValue>>
11390 for KeyValueBuilder<(T0, T1)>
11391 {
11392 type Prepared = ::planus::Offset<KeyValue>;
11393
11394 #[inline]
11395 fn prepare(
11396 &self,
11397 builder: &mut ::planus::Builder,
11398 ) -> ::core::option::Option<::planus::Offset<KeyValue>>
11399 {
11400 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
11401 self, builder,
11402 ))
11403 }
11404 }
11405
11406 impl<
11407 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11408 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
11409 > ::planus::WriteAsOffset<KeyValue> for KeyValueBuilder<(T0, T1)>
11410 {
11411 #[inline]
11412 fn prepare(
11413 &self,
11414 builder: &mut ::planus::Builder,
11415 ) -> ::planus::Offset<KeyValue> {
11416 let (v0, v1) = &self.0;
11417 KeyValue::create(builder, v0, v1)
11418 }
11419 }
11420
11421 /// Reference to a deserialized [KeyValue].
11422 #[derive(Copy, Clone)]
11423 pub struct KeyValueRef<'a>(::planus::table_reader::Table<'a>);
11424
11425 impl<'a> KeyValueRef<'a> {
11426 /// Getter for the [`key` field](KeyValue#structfield.key).
11427 #[inline]
11428 pub fn key(
11429 &self,
11430 ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>>
11431 {
11432 self.0.access(0, "KeyValue", "key")
11433 }
11434
11435 /// Getter for the [`value` field](KeyValue#structfield.value).
11436 #[inline]
11437 pub fn value(
11438 &self,
11439 ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>>
11440 {
11441 self.0.access(1, "KeyValue", "value")
11442 }
11443 }
11444
11445 impl<'a> ::core::fmt::Debug for KeyValueRef<'a> {
11446 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
11447 let mut f = f.debug_struct("KeyValueRef");
11448 if let ::core::option::Option::Some(field_key) = self.key().transpose()
11449 {
11450 f.field("key", &field_key);
11451 }
11452 if let ::core::option::Option::Some(field_value) =
11453 self.value().transpose()
11454 {
11455 f.field("value", &field_value);
11456 }
11457 f.finish()
11458 }
11459 }
11460
11461 impl<'a> ::core::convert::TryFrom<KeyValueRef<'a>> for KeyValue {
11462 type Error = ::planus::Error;
11463
11464 #[allow(unreachable_code)]
11465 fn try_from(value: KeyValueRef<'a>) -> ::planus::Result<Self> {
11466 ::core::result::Result::Ok(Self {
11467 key: value.key()?.map(::core::convert::Into::into),
11468 value: value.value()?.map(::core::convert::Into::into),
11469 })
11470 }
11471 }
11472
11473 impl<'a> ::planus::TableRead<'a> for KeyValueRef<'a> {
11474 #[inline]
11475 fn from_buffer(
11476 buffer: ::planus::SliceWithStartOffset<'a>,
11477 offset: usize,
11478 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
11479 {
11480 ::core::result::Result::Ok(Self(
11481 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
11482 ))
11483 }
11484 }
11485
11486 impl<'a> ::planus::VectorReadInner<'a> for KeyValueRef<'a> {
11487 type Error = ::planus::Error;
11488 const STRIDE: usize = 4;
11489
11490 unsafe fn from_buffer(
11491 buffer: ::planus::SliceWithStartOffset<'a>,
11492 offset: usize,
11493 ) -> ::planus::Result<Self> {
11494 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
11495 error_kind.with_error_location(
11496 "[KeyValueRef]",
11497 "get",
11498 buffer.offset_from_start,
11499 )
11500 })
11501 }
11502 }
11503
11504 /// # Safety
11505 /// The planus compiler generates implementations that initialize
11506 /// the bytes in `write_values`.
11507 unsafe impl ::planus::VectorWrite<::planus::Offset<KeyValue>> for KeyValue {
11508 type Value = ::planus::Offset<KeyValue>;
11509 const STRIDE: usize = 4;
11510 #[inline]
11511 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
11512 ::planus::WriteAs::prepare(self, builder)
11513 }
11514
11515 #[inline]
11516 unsafe fn write_values(
11517 values: &[::planus::Offset<KeyValue>],
11518 bytes: *mut ::core::mem::MaybeUninit<u8>,
11519 buffer_position: u32,
11520 ) {
11521 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
11522 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
11523 ::planus::WriteAsPrimitive::write(
11524 v,
11525 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
11526 buffer_position - (Self::STRIDE * i) as u32,
11527 );
11528 }
11529 }
11530 }
11531
11532 impl<'a> ::planus::ReadAsRoot<'a> for KeyValueRef<'a> {
11533 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
11534 ::planus::TableRead::from_buffer(
11535 ::planus::SliceWithStartOffset {
11536 buffer: slice,
11537 offset_from_start: 0,
11538 },
11539 0,
11540 )
11541 .map_err(|error_kind| {
11542 error_kind.with_error_location("[KeyValueRef]", "read_as_root", 0)
11543 })
11544 }
11545 }
11546
11547 /// ----------------------------------------------------------------------
11548 /// Dictionary encoding metadata
11549 /// Maintained for forwards compatibility, in the future
11550 /// Dictionaries might be explicit maps between integers and values
11551 /// allowing for non-contiguous index values
11552 ///
11553 /// Generated from these locations:
11554 /// * Enum `DictionaryKind` in the file `Schema.fbs:485`
11555 #[derive(
11556 Copy,
11557 Clone,
11558 Debug,
11559 PartialEq,
11560 Eq,
11561 PartialOrd,
11562 Ord,
11563 Hash,
11564 ::serde::Serialize,
11565 ::serde::Deserialize,
11566 )]
11567 #[repr(i16)]
11568 pub enum DictionaryKind {
11569 /// The variant `DenseArray` in the enum `DictionaryKind`
11570 DenseArray = 0,
11571 }
11572
11573 impl DictionaryKind {
11574 /// Array containing all valid variants of DictionaryKind
11575 pub const ENUM_VALUES: [Self; 1] = [Self::DenseArray];
11576 }
11577
11578 impl ::core::convert::TryFrom<i16> for DictionaryKind {
11579 type Error = ::planus::errors::UnknownEnumTagKind;
11580 #[inline]
11581 fn try_from(
11582 value: i16,
11583 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
11584 {
11585 #[allow(clippy::match_single_binding)]
11586 match value {
11587 0 => ::core::result::Result::Ok(DictionaryKind::DenseArray),
11588
11589 _ => ::core::result::Result::Err(
11590 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
11591 ),
11592 }
11593 }
11594 }
11595
11596 impl ::core::convert::From<DictionaryKind> for i16 {
11597 #[inline]
11598 fn from(value: DictionaryKind) -> Self {
11599 value as i16
11600 }
11601 }
11602
11603 /// # Safety
11604 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
11605 unsafe impl ::planus::Primitive for DictionaryKind {
11606 const ALIGNMENT: usize = 2;
11607 const SIZE: usize = 2;
11608 }
11609
11610 impl ::planus::WriteAsPrimitive<DictionaryKind> for DictionaryKind {
11611 #[inline]
11612 fn write<const N: usize>(
11613 &self,
11614 cursor: ::planus::Cursor<'_, N>,
11615 buffer_position: u32,
11616 ) {
11617 (*self as i16).write(cursor, buffer_position);
11618 }
11619 }
11620
11621 impl ::planus::WriteAs<DictionaryKind> for DictionaryKind {
11622 type Prepared = Self;
11623
11624 #[inline]
11625 fn prepare(&self, _builder: &mut ::planus::Builder) -> DictionaryKind {
11626 *self
11627 }
11628 }
11629
11630 impl ::planus::WriteAsDefault<DictionaryKind, DictionaryKind> for DictionaryKind {
11631 type Prepared = Self;
11632
11633 #[inline]
11634 fn prepare(
11635 &self,
11636 _builder: &mut ::planus::Builder,
11637 default: &DictionaryKind,
11638 ) -> ::core::option::Option<DictionaryKind> {
11639 if self == default {
11640 ::core::option::Option::None
11641 } else {
11642 ::core::option::Option::Some(*self)
11643 }
11644 }
11645 }
11646
11647 impl ::planus::WriteAsOptional<DictionaryKind> for DictionaryKind {
11648 type Prepared = Self;
11649
11650 #[inline]
11651 fn prepare(
11652 &self,
11653 _builder: &mut ::planus::Builder,
11654 ) -> ::core::option::Option<DictionaryKind> {
11655 ::core::option::Option::Some(*self)
11656 }
11657 }
11658
11659 impl<'buf> ::planus::TableRead<'buf> for DictionaryKind {
11660 #[inline]
11661 fn from_buffer(
11662 buffer: ::planus::SliceWithStartOffset<'buf>,
11663 offset: usize,
11664 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
11665 {
11666 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
11667 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
11668 }
11669 }
11670
11671 impl<'buf> ::planus::VectorReadInner<'buf> for DictionaryKind {
11672 type Error = ::planus::errors::UnknownEnumTag;
11673 const STRIDE: usize = 2;
11674 #[inline]
11675 unsafe fn from_buffer(
11676 buffer: ::planus::SliceWithStartOffset<'buf>,
11677 offset: usize,
11678 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
11679 {
11680 let value = unsafe {
11681 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
11682 };
11683 let value: ::core::result::Result<Self, _> =
11684 ::core::convert::TryInto::try_into(value);
11685 value.map_err(|error_kind| {
11686 error_kind.with_error_location(
11687 "DictionaryKind",
11688 "VectorRead::from_buffer",
11689 buffer.offset_from_start,
11690 )
11691 })
11692 }
11693 }
11694
11695 /// # Safety
11696 /// The planus compiler generates implementations that initialize
11697 /// the bytes in `write_values`.
11698 unsafe impl ::planus::VectorWrite<DictionaryKind> for DictionaryKind {
11699 const STRIDE: usize = 2;
11700
11701 type Value = Self;
11702
11703 #[inline]
11704 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
11705 *self
11706 }
11707
11708 #[inline]
11709 unsafe fn write_values(
11710 values: &[Self],
11711 bytes: *mut ::core::mem::MaybeUninit<u8>,
11712 buffer_position: u32,
11713 ) {
11714 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
11715 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
11716 ::planus::WriteAsPrimitive::write(
11717 v,
11718 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
11719 buffer_position - (2 * i) as u32,
11720 );
11721 }
11722 }
11723 }
11724
11725 /// The table `DictionaryEncoding` in the namespace `org.apache.arrow.flatbuf`
11726 ///
11727 /// Generated from these locations:
11728 /// * Table `DictionaryEncoding` in the file `Schema.fbs:486`
11729 #[derive(
11730 Clone,
11731 Debug,
11732 PartialEq,
11733 PartialOrd,
11734 Eq,
11735 Ord,
11736 Hash,
11737 ::serde::Serialize,
11738 ::serde::Deserialize,
11739 )]
11740 pub struct DictionaryEncoding {
11741 /// The known dictionary id in the application where this data is used. In
11742 /// the file or streaming formats, the dictionary ids are found in the
11743 /// DictionaryBatch messages
11744 pub id: i64,
11745 /// The dictionary indices are constrained to be non-negative integers. If
11746 /// this field is null, the indices must be signed int32. To maximize
11747 /// cross-language compatibility and performance, implementations are
11748 /// recommended to prefer signed integer types over unsigned integer types
11749 /// and to avoid uint64 indices unless they are required by an application.
11750 pub index_type:
11751 ::core::option::Option<::planus::alloc::boxed::Box<self::Int>>,
11752 /// By default, dictionaries are not ordered, or the order does not have
11753 /// semantic meaning. In some statistical, applications, dictionary-encoding
11754 /// is used to represent ordered categorical data, and we provide a way to
11755 /// preserve that metadata here
11756 pub is_ordered: bool,
11757 /// The field `dictionaryKind` in the table `DictionaryEncoding`
11758 pub dictionary_kind: self::DictionaryKind,
11759 }
11760
11761 #[allow(clippy::derivable_impls)]
11762 impl ::core::default::Default for DictionaryEncoding {
11763 fn default() -> Self {
11764 Self {
11765 id: 0,
11766 index_type: ::core::default::Default::default(),
11767 is_ordered: false,
11768 dictionary_kind: self::DictionaryKind::DenseArray,
11769 }
11770 }
11771 }
11772
11773 impl DictionaryEncoding {
11774 /// Creates a [DictionaryEncodingBuilder] for serializing an instance of this table.
11775 #[inline]
11776 pub fn builder() -> DictionaryEncodingBuilder<()> {
11777 DictionaryEncodingBuilder(())
11778 }
11779
11780 #[allow(clippy::too_many_arguments)]
11781 pub fn create(
11782 builder: &mut ::planus::Builder,
11783 field_id: impl ::planus::WriteAsDefault<i64, i64>,
11784 field_index_type: impl ::planus::WriteAsOptional<
11785 ::planus::Offset<self::Int>,
11786 >,
11787 field_is_ordered: impl ::planus::WriteAsDefault<bool, bool>,
11788 field_dictionary_kind: impl ::planus::WriteAsDefault<
11789 self::DictionaryKind,
11790 self::DictionaryKind,
11791 >,
11792 ) -> ::planus::Offset<Self> {
11793 let prepared_id = field_id.prepare(builder, &0);
11794 let prepared_index_type = field_index_type.prepare(builder);
11795 let prepared_is_ordered = field_is_ordered.prepare(builder, &false);
11796 let prepared_dictionary_kind = field_dictionary_kind
11797 .prepare(builder, &self::DictionaryKind::DenseArray);
11798
11799 let mut table_writer: ::planus::table_writer::TableWriter<12> =
11800 ::core::default::Default::default();
11801 if prepared_id.is_some() {
11802 table_writer.write_entry::<i64>(0);
11803 }
11804 if prepared_index_type.is_some() {
11805 table_writer.write_entry::<::planus::Offset<self::Int>>(1);
11806 }
11807 if prepared_dictionary_kind.is_some() {
11808 table_writer.write_entry::<self::DictionaryKind>(3);
11809 }
11810 if prepared_is_ordered.is_some() {
11811 table_writer.write_entry::<bool>(2);
11812 }
11813
11814 unsafe {
11815 table_writer.finish(builder, |object_writer| {
11816 if let ::core::option::Option::Some(prepared_id) = prepared_id {
11817 object_writer.write::<_, _, 8>(&prepared_id);
11818 }
11819 if let ::core::option::Option::Some(prepared_index_type) =
11820 prepared_index_type
11821 {
11822 object_writer.write::<_, _, 4>(&prepared_index_type);
11823 }
11824 if let ::core::option::Option::Some(prepared_dictionary_kind) =
11825 prepared_dictionary_kind
11826 {
11827 object_writer.write::<_, _, 2>(&prepared_dictionary_kind);
11828 }
11829 if let ::core::option::Option::Some(prepared_is_ordered) =
11830 prepared_is_ordered
11831 {
11832 object_writer.write::<_, _, 1>(&prepared_is_ordered);
11833 }
11834 });
11835 }
11836 builder.current_offset()
11837 }
11838 }
11839
11840 impl ::planus::WriteAs<::planus::Offset<DictionaryEncoding>> for DictionaryEncoding {
11841 type Prepared = ::planus::Offset<Self>;
11842
11843 #[inline]
11844 fn prepare(
11845 &self,
11846 builder: &mut ::planus::Builder,
11847 ) -> ::planus::Offset<DictionaryEncoding> {
11848 ::planus::WriteAsOffset::prepare(self, builder)
11849 }
11850 }
11851
11852 impl ::planus::WriteAsOptional<::planus::Offset<DictionaryEncoding>> for DictionaryEncoding {
11853 type Prepared = ::planus::Offset<Self>;
11854
11855 #[inline]
11856 fn prepare(
11857 &self,
11858 builder: &mut ::planus::Builder,
11859 ) -> ::core::option::Option<::planus::Offset<DictionaryEncoding>>
11860 {
11861 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
11862 self, builder,
11863 ))
11864 }
11865 }
11866
11867 impl ::planus::WriteAsOffset<DictionaryEncoding> for DictionaryEncoding {
11868 #[inline]
11869 fn prepare(
11870 &self,
11871 builder: &mut ::planus::Builder,
11872 ) -> ::planus::Offset<DictionaryEncoding> {
11873 DictionaryEncoding::create(
11874 builder,
11875 self.id,
11876 &self.index_type,
11877 self.is_ordered,
11878 self.dictionary_kind,
11879 )
11880 }
11881 }
11882
11883 /// Builder for serializing an instance of the [DictionaryEncoding] type.
11884 ///
11885 /// Can be created using the [DictionaryEncoding::builder] method.
11886 #[derive(Debug)]
11887 #[must_use]
11888 pub struct DictionaryEncodingBuilder<State>(State);
11889
11890 impl DictionaryEncodingBuilder<()> {
11891 /// Setter for the [`id` field](DictionaryEncoding#structfield.id).
11892 #[inline]
11893 #[allow(clippy::type_complexity)]
11894 pub fn id<T0>(self, value: T0) -> DictionaryEncodingBuilder<(T0,)>
11895 where
11896 T0: ::planus::WriteAsDefault<i64, i64>,
11897 {
11898 DictionaryEncodingBuilder((value,))
11899 }
11900
11901 /// Sets the [`id` field](DictionaryEncoding#structfield.id) to the default value.
11902 #[inline]
11903 #[allow(clippy::type_complexity)]
11904 pub fn id_as_default(
11905 self,
11906 ) -> DictionaryEncodingBuilder<(::planus::DefaultValue,)>
11907 {
11908 self.id(::planus::DefaultValue)
11909 }
11910 }
11911
11912 impl<T0> DictionaryEncodingBuilder<(T0,)> {
11913 /// Setter for the [`indexType` field](DictionaryEncoding#structfield.index_type).
11914 #[inline]
11915 #[allow(clippy::type_complexity)]
11916 pub fn index_type<T1>(
11917 self,
11918 value: T1,
11919 ) -> DictionaryEncodingBuilder<(T0, T1)>
11920 where
11921 T1: ::planus::WriteAsOptional<::planus::Offset<self::Int>>,
11922 {
11923 let (v0,) = self.0;
11924 DictionaryEncodingBuilder((v0, value))
11925 }
11926
11927 /// Sets the [`indexType` field](DictionaryEncoding#structfield.index_type) to null.
11928 #[inline]
11929 #[allow(clippy::type_complexity)]
11930 pub fn index_type_as_null(self) -> DictionaryEncodingBuilder<(T0, ())> {
11931 self.index_type(())
11932 }
11933 }
11934
11935 impl<T0, T1> DictionaryEncodingBuilder<(T0, T1)> {
11936 /// Setter for the [`isOrdered` field](DictionaryEncoding#structfield.is_ordered).
11937 #[inline]
11938 #[allow(clippy::type_complexity)]
11939 pub fn is_ordered<T2>(
11940 self,
11941 value: T2,
11942 ) -> DictionaryEncodingBuilder<(T0, T1, T2)>
11943 where
11944 T2: ::planus::WriteAsDefault<bool, bool>,
11945 {
11946 let (v0, v1) = self.0;
11947 DictionaryEncodingBuilder((v0, v1, value))
11948 }
11949
11950 /// Sets the [`isOrdered` field](DictionaryEncoding#structfield.is_ordered) to the default value.
11951 #[inline]
11952 #[allow(clippy::type_complexity)]
11953 pub fn is_ordered_as_default(
11954 self,
11955 ) -> DictionaryEncodingBuilder<(T0, T1, ::planus::DefaultValue)>
11956 {
11957 self.is_ordered(::planus::DefaultValue)
11958 }
11959 }
11960
11961 impl<T0, T1, T2> DictionaryEncodingBuilder<(T0, T1, T2)> {
11962 /// Setter for the [`dictionaryKind` field](DictionaryEncoding#structfield.dictionary_kind).
11963 #[inline]
11964 #[allow(clippy::type_complexity)]
11965 pub fn dictionary_kind<T3>(
11966 self,
11967 value: T3,
11968 ) -> DictionaryEncodingBuilder<(T0, T1, T2, T3)>
11969 where
11970 T3: ::planus::WriteAsDefault<
11971 self::DictionaryKind,
11972 self::DictionaryKind,
11973 >,
11974 {
11975 let (v0, v1, v2) = self.0;
11976 DictionaryEncodingBuilder((v0, v1, v2, value))
11977 }
11978
11979 /// Sets the [`dictionaryKind` field](DictionaryEncoding#structfield.dictionary_kind) to the default value.
11980 #[inline]
11981 #[allow(clippy::type_complexity)]
11982 pub fn dictionary_kind_as_default(
11983 self,
11984 ) -> DictionaryEncodingBuilder<(T0, T1, T2, ::planus::DefaultValue)>
11985 {
11986 self.dictionary_kind(::planus::DefaultValue)
11987 }
11988 }
11989
11990 impl<T0, T1, T2, T3> DictionaryEncodingBuilder<(T0, T1, T2, T3)> {
11991 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DictionaryEncoding].
11992 #[inline]
11993 pub fn finish(
11994 self,
11995 builder: &mut ::planus::Builder,
11996 ) -> ::planus::Offset<DictionaryEncoding>
11997 where
11998 Self: ::planus::WriteAsOffset<DictionaryEncoding>,
11999 {
12000 ::planus::WriteAsOffset::prepare(&self, builder)
12001 }
12002 }
12003
12004 impl<
12005 T0: ::planus::WriteAsDefault<i64, i64>,
12006 T1: ::planus::WriteAsOptional<::planus::Offset<self::Int>>,
12007 T2: ::planus::WriteAsDefault<bool, bool>,
12008 T3: ::planus::WriteAsDefault<self::DictionaryKind, self::DictionaryKind>,
12009 >
12010 ::planus::WriteAs<::planus::Offset<DictionaryEncoding>>
12011 for DictionaryEncodingBuilder<(T0, T1, T2, T3)>
12012 {
12013 type Prepared = ::planus::Offset<DictionaryEncoding>;
12014
12015 #[inline]
12016 fn prepare(
12017 &self,
12018 builder: &mut ::planus::Builder,
12019 ) -> ::planus::Offset<DictionaryEncoding> {
12020 ::planus::WriteAsOffset::prepare(self, builder)
12021 }
12022 }
12023
12024 impl<
12025 T0: ::planus::WriteAsDefault<i64, i64>,
12026 T1: ::planus::WriteAsOptional<::planus::Offset<self::Int>>,
12027 T2: ::planus::WriteAsDefault<bool, bool>,
12028 T3: ::planus::WriteAsDefault<self::DictionaryKind, self::DictionaryKind>,
12029 >
12030 ::planus::WriteAsOptional<::planus::Offset<DictionaryEncoding>>
12031 for DictionaryEncodingBuilder<(T0, T1, T2, T3)>
12032 {
12033 type Prepared = ::planus::Offset<DictionaryEncoding>;
12034
12035 #[inline]
12036 fn prepare(
12037 &self,
12038 builder: &mut ::planus::Builder,
12039 ) -> ::core::option::Option<::planus::Offset<DictionaryEncoding>>
12040 {
12041 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
12042 self, builder,
12043 ))
12044 }
12045 }
12046
12047 impl<
12048 T0: ::planus::WriteAsDefault<i64, i64>,
12049 T1: ::planus::WriteAsOptional<::planus::Offset<self::Int>>,
12050 T2: ::planus::WriteAsDefault<bool, bool>,
12051 T3: ::planus::WriteAsDefault<self::DictionaryKind, self::DictionaryKind>,
12052 > ::planus::WriteAsOffset<DictionaryEncoding>
12053 for DictionaryEncodingBuilder<(T0, T1, T2, T3)>
12054 {
12055 #[inline]
12056 fn prepare(
12057 &self,
12058 builder: &mut ::planus::Builder,
12059 ) -> ::planus::Offset<DictionaryEncoding> {
12060 let (v0, v1, v2, v3) = &self.0;
12061 DictionaryEncoding::create(builder, v0, v1, v2, v3)
12062 }
12063 }
12064
12065 /// Reference to a deserialized [DictionaryEncoding].
12066 #[derive(Copy, Clone)]
12067 pub struct DictionaryEncodingRef<'a>(::planus::table_reader::Table<'a>);
12068
12069 impl<'a> DictionaryEncodingRef<'a> {
12070 /// Getter for the [`id` field](DictionaryEncoding#structfield.id).
12071 #[inline]
12072 pub fn id(&self) -> ::planus::Result<i64> {
12073 ::core::result::Result::Ok(
12074 self.0.access(0, "DictionaryEncoding", "id")?.unwrap_or(0),
12075 )
12076 }
12077
12078 /// Getter for the [`indexType` field](DictionaryEncoding#structfield.index_type).
12079 #[inline]
12080 pub fn index_type(
12081 &self,
12082 ) -> ::planus::Result<::core::option::Option<self::IntRef<'a>>>
12083 {
12084 self.0.access(1, "DictionaryEncoding", "index_type")
12085 }
12086
12087 /// Getter for the [`isOrdered` field](DictionaryEncoding#structfield.is_ordered).
12088 #[inline]
12089 pub fn is_ordered(&self) -> ::planus::Result<bool> {
12090 ::core::result::Result::Ok(
12091 self.0
12092 .access(2, "DictionaryEncoding", "is_ordered")?
12093 .unwrap_or(false),
12094 )
12095 }
12096
12097 /// Getter for the [`dictionaryKind` field](DictionaryEncoding#structfield.dictionary_kind).
12098 #[inline]
12099 pub fn dictionary_kind(&self) -> ::planus::Result<self::DictionaryKind> {
12100 ::core::result::Result::Ok(
12101 self.0
12102 .access(3, "DictionaryEncoding", "dictionary_kind")?
12103 .unwrap_or(self::DictionaryKind::DenseArray),
12104 )
12105 }
12106 }
12107
12108 impl<'a> ::core::fmt::Debug for DictionaryEncodingRef<'a> {
12109 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
12110 let mut f = f.debug_struct("DictionaryEncodingRef");
12111 f.field("id", &self.id());
12112 if let ::core::option::Option::Some(field_index_type) =
12113 self.index_type().transpose()
12114 {
12115 f.field("index_type", &field_index_type);
12116 }
12117 f.field("is_ordered", &self.is_ordered());
12118 f.field("dictionary_kind", &self.dictionary_kind());
12119 f.finish()
12120 }
12121 }
12122
12123 impl<'a> ::core::convert::TryFrom<DictionaryEncodingRef<'a>> for DictionaryEncoding {
12124 type Error = ::planus::Error;
12125
12126 #[allow(unreachable_code)]
12127 fn try_from(value: DictionaryEncodingRef<'a>) -> ::planus::Result<Self> {
12128 ::core::result::Result::Ok(Self {
12129 id: ::core::convert::TryInto::try_into(value.id()?)?,
12130 index_type: if let ::core::option::Option::Some(index_type) =
12131 value.index_type()?
12132 {
12133 ::core::option::Option::Some(::planus::alloc::boxed::Box::new(
12134 ::core::convert::TryInto::try_into(index_type)?,
12135 ))
12136 } else {
12137 ::core::option::Option::None
12138 },
12139 is_ordered: ::core::convert::TryInto::try_into(
12140 value.is_ordered()?,
12141 )?,
12142 dictionary_kind: ::core::convert::TryInto::try_into(
12143 value.dictionary_kind()?,
12144 )?,
12145 })
12146 }
12147 }
12148
12149 impl<'a> ::planus::TableRead<'a> for DictionaryEncodingRef<'a> {
12150 #[inline]
12151 fn from_buffer(
12152 buffer: ::planus::SliceWithStartOffset<'a>,
12153 offset: usize,
12154 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
12155 {
12156 ::core::result::Result::Ok(Self(
12157 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
12158 ))
12159 }
12160 }
12161
12162 impl<'a> ::planus::VectorReadInner<'a> for DictionaryEncodingRef<'a> {
12163 type Error = ::planus::Error;
12164 const STRIDE: usize = 4;
12165
12166 unsafe fn from_buffer(
12167 buffer: ::planus::SliceWithStartOffset<'a>,
12168 offset: usize,
12169 ) -> ::planus::Result<Self> {
12170 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
12171 error_kind.with_error_location(
12172 "[DictionaryEncodingRef]",
12173 "get",
12174 buffer.offset_from_start,
12175 )
12176 })
12177 }
12178 }
12179
12180 /// # Safety
12181 /// The planus compiler generates implementations that initialize
12182 /// the bytes in `write_values`.
12183 unsafe impl ::planus::VectorWrite<::planus::Offset<DictionaryEncoding>> for DictionaryEncoding {
12184 type Value = ::planus::Offset<DictionaryEncoding>;
12185 const STRIDE: usize = 4;
12186 #[inline]
12187 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
12188 ::planus::WriteAs::prepare(self, builder)
12189 }
12190
12191 #[inline]
12192 unsafe fn write_values(
12193 values: &[::planus::Offset<DictionaryEncoding>],
12194 bytes: *mut ::core::mem::MaybeUninit<u8>,
12195 buffer_position: u32,
12196 ) {
12197 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
12198 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
12199 ::planus::WriteAsPrimitive::write(
12200 v,
12201 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
12202 buffer_position - (Self::STRIDE * i) as u32,
12203 );
12204 }
12205 }
12206 }
12207
12208 impl<'a> ::planus::ReadAsRoot<'a> for DictionaryEncodingRef<'a> {
12209 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
12210 ::planus::TableRead::from_buffer(
12211 ::planus::SliceWithStartOffset {
12212 buffer: slice,
12213 offset_from_start: 0,
12214 },
12215 0,
12216 )
12217 .map_err(|error_kind| {
12218 error_kind.with_error_location(
12219 "[DictionaryEncodingRef]",
12220 "read_as_root",
12221 0,
12222 )
12223 })
12224 }
12225 }
12226
12227 /// ----------------------------------------------------------------------
12228 /// A field represents a named column in a record / row batch or child of a
12229 /// nested type.
12230 ///
12231 /// Generated from these locations:
12232 /// * Table `Field` in the file `Schema.fbs:512`
12233 #[derive(
12234 Clone,
12235 Debug,
12236 PartialEq,
12237 PartialOrd,
12238 Eq,
12239 Ord,
12240 Hash,
12241 ::serde::Serialize,
12242 ::serde::Deserialize,
12243 )]
12244 pub struct Field {
12245 /// Name is not required (e.g., in a List)
12246 pub name: ::core::option::Option<::planus::alloc::string::String>,
12247 /// Whether or not this field can contain nulls. Should be true in general.
12248 pub nullable: bool,
12249 /// This is the type of the decoded value if the field is dictionary encoded.
12250 pub type_: ::core::option::Option<self::Type>,
12251 /// Present only if the field is dictionary encoded.
12252 pub dictionary: ::core::option::Option<
12253 ::planus::alloc::boxed::Box<self::DictionaryEncoding>,
12254 >,
12255 /// children apply only to nested data types like Struct, List and Union. For
12256 /// primitive types children will have length 0.
12257 pub children:
12258 ::core::option::Option<::planus::alloc::vec::Vec<self::Field>>,
12259 /// User-defined metadata
12260 pub custom_metadata:
12261 ::core::option::Option<::planus::alloc::vec::Vec<self::KeyValue>>,
12262 }
12263
12264 #[allow(clippy::derivable_impls)]
12265 impl ::core::default::Default for Field {
12266 fn default() -> Self {
12267 Self {
12268 name: ::core::default::Default::default(),
12269 nullable: false,
12270 type_: ::core::default::Default::default(),
12271 dictionary: ::core::default::Default::default(),
12272 children: ::core::default::Default::default(),
12273 custom_metadata: ::core::default::Default::default(),
12274 }
12275 }
12276 }
12277
12278 impl Field {
12279 /// Creates a [FieldBuilder] for serializing an instance of this table.
12280 #[inline]
12281 pub fn builder() -> FieldBuilder<()> {
12282 FieldBuilder(())
12283 }
12284
12285 #[allow(clippy::too_many_arguments)]
12286 pub fn create(
12287 builder: &mut ::planus::Builder,
12288 field_name: impl ::planus::WriteAsOptional<
12289 ::planus::Offset<::core::primitive::str>,
12290 >,
12291 field_nullable: impl ::planus::WriteAsDefault<bool, bool>,
12292 field_type_: impl ::planus::WriteAsOptionalUnion<self::Type>,
12293 field_dictionary: impl ::planus::WriteAsOptional<
12294 ::planus::Offset<self::DictionaryEncoding>,
12295 >,
12296 field_children: impl ::planus::WriteAsOptional<
12297 ::planus::Offset<[::planus::Offset<self::Field>]>,
12298 >,
12299 field_custom_metadata: impl ::planus::WriteAsOptional<
12300 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
12301 >,
12302 ) -> ::planus::Offset<Self> {
12303 let prepared_name = field_name.prepare(builder);
12304 let prepared_nullable = field_nullable.prepare(builder, &false);
12305 let prepared_type_ = field_type_.prepare(builder);
12306 let prepared_dictionary = field_dictionary.prepare(builder);
12307 let prepared_children = field_children.prepare(builder);
12308 let prepared_custom_metadata = field_custom_metadata.prepare(builder);
12309
12310 let mut table_writer: ::planus::table_writer::TableWriter<18> =
12311 ::core::default::Default::default();
12312 if prepared_name.is_some() {
12313 table_writer.write_entry::<::planus::Offset<str>>(0);
12314 }
12315 if prepared_type_.is_some() {
12316 table_writer.write_entry::<::planus::Offset<self::Type>>(3);
12317 }
12318 if prepared_dictionary.is_some() {
12319 table_writer
12320 .write_entry::<::planus::Offset<self::DictionaryEncoding>>(4);
12321 }
12322 if prepared_children.is_some() {
12323 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::Field>]>>(5);
12324 }
12325 if prepared_custom_metadata.is_some() {
12326 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::KeyValue>]>>(6);
12327 }
12328 if prepared_nullable.is_some() {
12329 table_writer.write_entry::<bool>(1);
12330 }
12331 if prepared_type_.is_some() {
12332 table_writer.write_entry::<u8>(2);
12333 }
12334
12335 unsafe {
12336 table_writer.finish(builder, |object_writer| {
12337 if let ::core::option::Option::Some(prepared_name) =
12338 prepared_name
12339 {
12340 object_writer.write::<_, _, 4>(&prepared_name);
12341 }
12342 if let ::core::option::Option::Some(prepared_type_) =
12343 prepared_type_
12344 {
12345 object_writer.write::<_, _, 4>(&prepared_type_.offset());
12346 }
12347 if let ::core::option::Option::Some(prepared_dictionary) =
12348 prepared_dictionary
12349 {
12350 object_writer.write::<_, _, 4>(&prepared_dictionary);
12351 }
12352 if let ::core::option::Option::Some(prepared_children) =
12353 prepared_children
12354 {
12355 object_writer.write::<_, _, 4>(&prepared_children);
12356 }
12357 if let ::core::option::Option::Some(prepared_custom_metadata) =
12358 prepared_custom_metadata
12359 {
12360 object_writer.write::<_, _, 4>(&prepared_custom_metadata);
12361 }
12362 if let ::core::option::Option::Some(prepared_nullable) =
12363 prepared_nullable
12364 {
12365 object_writer.write::<_, _, 1>(&prepared_nullable);
12366 }
12367 if let ::core::option::Option::Some(prepared_type_) =
12368 prepared_type_
12369 {
12370 object_writer.write::<_, _, 1>(&prepared_type_.tag());
12371 }
12372 });
12373 }
12374 builder.current_offset()
12375 }
12376 }
12377
12378 impl ::planus::WriteAs<::planus::Offset<Field>> for Field {
12379 type Prepared = ::planus::Offset<Self>;
12380
12381 #[inline]
12382 fn prepare(
12383 &self,
12384 builder: &mut ::planus::Builder,
12385 ) -> ::planus::Offset<Field> {
12386 ::planus::WriteAsOffset::prepare(self, builder)
12387 }
12388 }
12389
12390 impl ::planus::WriteAsOptional<::planus::Offset<Field>> for Field {
12391 type Prepared = ::planus::Offset<Self>;
12392
12393 #[inline]
12394 fn prepare(
12395 &self,
12396 builder: &mut ::planus::Builder,
12397 ) -> ::core::option::Option<::planus::Offset<Field>>
12398 {
12399 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
12400 self, builder,
12401 ))
12402 }
12403 }
12404
12405 impl ::planus::WriteAsOffset<Field> for Field {
12406 #[inline]
12407 fn prepare(
12408 &self,
12409 builder: &mut ::planus::Builder,
12410 ) -> ::planus::Offset<Field> {
12411 Field::create(
12412 builder,
12413 &self.name,
12414 self.nullable,
12415 &self.type_,
12416 &self.dictionary,
12417 &self.children,
12418 &self.custom_metadata,
12419 )
12420 }
12421 }
12422
12423 /// Builder for serializing an instance of the [Field] type.
12424 ///
12425 /// Can be created using the [Field::builder] method.
12426 #[derive(Debug)]
12427 #[must_use]
12428 pub struct FieldBuilder<State>(State);
12429
12430 impl FieldBuilder<()> {
12431 /// Setter for the [`name` field](Field#structfield.name).
12432 #[inline]
12433 #[allow(clippy::type_complexity)]
12434 pub fn name<T0>(self, value: T0) -> FieldBuilder<(T0,)>
12435 where
12436 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
12437 {
12438 FieldBuilder((value,))
12439 }
12440
12441 /// Sets the [`name` field](Field#structfield.name) to null.
12442 #[inline]
12443 #[allow(clippy::type_complexity)]
12444 pub fn name_as_null(self) -> FieldBuilder<((),)> {
12445 self.name(())
12446 }
12447 }
12448
12449 impl<T0> FieldBuilder<(T0,)> {
12450 /// Setter for the [`nullable` field](Field#structfield.nullable).
12451 #[inline]
12452 #[allow(clippy::type_complexity)]
12453 pub fn nullable<T1>(self, value: T1) -> FieldBuilder<(T0, T1)>
12454 where
12455 T1: ::planus::WriteAsDefault<bool, bool>,
12456 {
12457 let (v0,) = self.0;
12458 FieldBuilder((v0, value))
12459 }
12460
12461 /// Sets the [`nullable` field](Field#structfield.nullable) to the default value.
12462 #[inline]
12463 #[allow(clippy::type_complexity)]
12464 pub fn nullable_as_default(
12465 self,
12466 ) -> FieldBuilder<(T0, ::planus::DefaultValue)> {
12467 self.nullable(::planus::DefaultValue)
12468 }
12469 }
12470
12471 impl<T0, T1> FieldBuilder<(T0, T1)> {
12472 /// Setter for the [`type` field](Field#structfield.type_).
12473 #[inline]
12474 #[allow(clippy::type_complexity)]
12475 pub fn type_<T2>(self, value: T2) -> FieldBuilder<(T0, T1, T2)>
12476 where
12477 T2: ::planus::WriteAsOptionalUnion<self::Type>,
12478 {
12479 let (v0, v1) = self.0;
12480 FieldBuilder((v0, v1, value))
12481 }
12482
12483 /// Sets the [`type` field](Field#structfield.type_) to null.
12484 #[inline]
12485 #[allow(clippy::type_complexity)]
12486 pub fn type_as_null(self) -> FieldBuilder<(T0, T1, ())> {
12487 self.type_(())
12488 }
12489 }
12490
12491 impl<T0, T1, T2> FieldBuilder<(T0, T1, T2)> {
12492 /// Setter for the [`dictionary` field](Field#structfield.dictionary).
12493 #[inline]
12494 #[allow(clippy::type_complexity)]
12495 pub fn dictionary<T3>(self, value: T3) -> FieldBuilder<(T0, T1, T2, T3)>
12496 where
12497 T3: ::planus::WriteAsOptional<
12498 ::planus::Offset<self::DictionaryEncoding>,
12499 >,
12500 {
12501 let (v0, v1, v2) = self.0;
12502 FieldBuilder((v0, v1, v2, value))
12503 }
12504
12505 /// Sets the [`dictionary` field](Field#structfield.dictionary) to null.
12506 #[inline]
12507 #[allow(clippy::type_complexity)]
12508 pub fn dictionary_as_null(self) -> FieldBuilder<(T0, T1, T2, ())> {
12509 self.dictionary(())
12510 }
12511 }
12512
12513 impl<T0, T1, T2, T3> FieldBuilder<(T0, T1, T2, T3)> {
12514 /// Setter for the [`children` field](Field#structfield.children).
12515 #[inline]
12516 #[allow(clippy::type_complexity)]
12517 pub fn children<T4>(self, value: T4) -> FieldBuilder<(T0, T1, T2, T3, T4)>
12518 where
12519 T4: ::planus::WriteAsOptional<
12520 ::planus::Offset<[::planus::Offset<self::Field>]>,
12521 >,
12522 {
12523 let (v0, v1, v2, v3) = self.0;
12524 FieldBuilder((v0, v1, v2, v3, value))
12525 }
12526
12527 /// Sets the [`children` field](Field#structfield.children) to null.
12528 #[inline]
12529 #[allow(clippy::type_complexity)]
12530 pub fn children_as_null(self) -> FieldBuilder<(T0, T1, T2, T3, ())> {
12531 self.children(())
12532 }
12533 }
12534
12535 impl<T0, T1, T2, T3, T4> FieldBuilder<(T0, T1, T2, T3, T4)> {
12536 /// Setter for the [`custom_metadata` field](Field#structfield.custom_metadata).
12537 #[inline]
12538 #[allow(clippy::type_complexity)]
12539 pub fn custom_metadata<T5>(
12540 self,
12541 value: T5,
12542 ) -> FieldBuilder<(T0, T1, T2, T3, T4, T5)>
12543 where
12544 T5: ::planus::WriteAsOptional<
12545 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
12546 >,
12547 {
12548 let (v0, v1, v2, v3, v4) = self.0;
12549 FieldBuilder((v0, v1, v2, v3, v4, value))
12550 }
12551
12552 /// Sets the [`custom_metadata` field](Field#structfield.custom_metadata) to null.
12553 #[inline]
12554 #[allow(clippy::type_complexity)]
12555 pub fn custom_metadata_as_null(
12556 self,
12557 ) -> FieldBuilder<(T0, T1, T2, T3, T4, ())> {
12558 self.custom_metadata(())
12559 }
12560 }
12561
12562 impl<T0, T1, T2, T3, T4, T5> FieldBuilder<(T0, T1, T2, T3, T4, T5)> {
12563 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Field].
12564 #[inline]
12565 pub fn finish(
12566 self,
12567 builder: &mut ::planus::Builder,
12568 ) -> ::planus::Offset<Field>
12569 where
12570 Self: ::planus::WriteAsOffset<Field>,
12571 {
12572 ::planus::WriteAsOffset::prepare(&self, builder)
12573 }
12574 }
12575
12576 impl<
12577 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
12578 T1: ::planus::WriteAsDefault<bool, bool>,
12579 T2: ::planus::WriteAsOptionalUnion<self::Type>,
12580 T3: ::planus::WriteAsOptional<::planus::Offset<self::DictionaryEncoding>>,
12581 T4: ::planus::WriteAsOptional<
12582 ::planus::Offset<[::planus::Offset<self::Field>]>,
12583 >,
12584 T5: ::planus::WriteAsOptional<
12585 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
12586 >,
12587 > ::planus::WriteAs<::planus::Offset<Field>>
12588 for FieldBuilder<(T0, T1, T2, T3, T4, T5)>
12589 {
12590 type Prepared = ::planus::Offset<Field>;
12591
12592 #[inline]
12593 fn prepare(
12594 &self,
12595 builder: &mut ::planus::Builder,
12596 ) -> ::planus::Offset<Field> {
12597 ::planus::WriteAsOffset::prepare(self, builder)
12598 }
12599 }
12600
12601 impl<
12602 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
12603 T1: ::planus::WriteAsDefault<bool, bool>,
12604 T2: ::planus::WriteAsOptionalUnion<self::Type>,
12605 T3: ::planus::WriteAsOptional<::planus::Offset<self::DictionaryEncoding>>,
12606 T4: ::planus::WriteAsOptional<
12607 ::planus::Offset<[::planus::Offset<self::Field>]>,
12608 >,
12609 T5: ::planus::WriteAsOptional<
12610 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
12611 >,
12612 > ::planus::WriteAsOptional<::planus::Offset<Field>>
12613 for FieldBuilder<(T0, T1, T2, T3, T4, T5)>
12614 {
12615 type Prepared = ::planus::Offset<Field>;
12616
12617 #[inline]
12618 fn prepare(
12619 &self,
12620 builder: &mut ::planus::Builder,
12621 ) -> ::core::option::Option<::planus::Offset<Field>>
12622 {
12623 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
12624 self, builder,
12625 ))
12626 }
12627 }
12628
12629 impl<
12630 T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
12631 T1: ::planus::WriteAsDefault<bool, bool>,
12632 T2: ::planus::WriteAsOptionalUnion<self::Type>,
12633 T3: ::planus::WriteAsOptional<::planus::Offset<self::DictionaryEncoding>>,
12634 T4: ::planus::WriteAsOptional<
12635 ::planus::Offset<[::planus::Offset<self::Field>]>,
12636 >,
12637 T5: ::planus::WriteAsOptional<
12638 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
12639 >,
12640 > ::planus::WriteAsOffset<Field>
12641 for FieldBuilder<(T0, T1, T2, T3, T4, T5)>
12642 {
12643 #[inline]
12644 fn prepare(
12645 &self,
12646 builder: &mut ::planus::Builder,
12647 ) -> ::planus::Offset<Field> {
12648 let (v0, v1, v2, v3, v4, v5) = &self.0;
12649 Field::create(builder, v0, v1, v2, v3, v4, v5)
12650 }
12651 }
12652
12653 /// Reference to a deserialized [Field].
12654 #[derive(Copy, Clone)]
12655 pub struct FieldRef<'a>(::planus::table_reader::Table<'a>);
12656
12657 impl<'a> FieldRef<'a> {
12658 /// Getter for the [`name` field](Field#structfield.name).
12659 #[inline]
12660 pub fn name(
12661 &self,
12662 ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>>
12663 {
12664 self.0.access(0, "Field", "name")
12665 }
12666
12667 /// Getter for the [`nullable` field](Field#structfield.nullable).
12668 #[inline]
12669 pub fn nullable(&self) -> ::planus::Result<bool> {
12670 ::core::result::Result::Ok(
12671 self.0.access(1, "Field", "nullable")?.unwrap_or(false),
12672 )
12673 }
12674
12675 /// Getter for the [`type` field](Field#structfield.type_).
12676 #[inline]
12677 pub fn type_(
12678 &self,
12679 ) -> ::planus::Result<::core::option::Option<self::TypeRef<'a>>>
12680 {
12681 self.0.access_union(2, "Field", "type_")
12682 }
12683
12684 /// Getter for the [`dictionary` field](Field#structfield.dictionary).
12685 #[inline]
12686 pub fn dictionary(
12687 &self,
12688 ) -> ::planus::Result<::core::option::Option<self::DictionaryEncodingRef<'a>>>
12689 {
12690 self.0.access(4, "Field", "dictionary")
12691 }
12692
12693 /// Getter for the [`children` field](Field#structfield.children).
12694 #[inline]
12695 pub fn children(
12696 &self,
12697 ) -> ::planus::Result<
12698 ::core::option::Option<
12699 ::planus::Vector<'a, ::planus::Result<self::FieldRef<'a>>>,
12700 >,
12701 > {
12702 self.0.access(5, "Field", "children")
12703 }
12704
12705 /// Getter for the [`custom_metadata` field](Field#structfield.custom_metadata).
12706 #[inline]
12707 pub fn custom_metadata(
12708 &self,
12709 ) -> ::planus::Result<
12710 ::core::option::Option<
12711 ::planus::Vector<'a, ::planus::Result<self::KeyValueRef<'a>>>,
12712 >,
12713 > {
12714 self.0.access(6, "Field", "custom_metadata")
12715 }
12716 }
12717
12718 impl<'a> ::core::fmt::Debug for FieldRef<'a> {
12719 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
12720 let mut f = f.debug_struct("FieldRef");
12721 if let ::core::option::Option::Some(field_name) =
12722 self.name().transpose()
12723 {
12724 f.field("name", &field_name);
12725 }
12726 f.field("nullable", &self.nullable());
12727 if let ::core::option::Option::Some(field_type_) =
12728 self.type_().transpose()
12729 {
12730 f.field("type_", &field_type_);
12731 }
12732 if let ::core::option::Option::Some(field_dictionary) =
12733 self.dictionary().transpose()
12734 {
12735 f.field("dictionary", &field_dictionary);
12736 }
12737 if let ::core::option::Option::Some(field_children) =
12738 self.children().transpose()
12739 {
12740 f.field("children", &field_children);
12741 }
12742 if let ::core::option::Option::Some(field_custom_metadata) =
12743 self.custom_metadata().transpose()
12744 {
12745 f.field("custom_metadata", &field_custom_metadata);
12746 }
12747 f.finish()
12748 }
12749 }
12750
12751 impl<'a> ::core::convert::TryFrom<FieldRef<'a>> for Field {
12752 type Error = ::planus::Error;
12753
12754 #[allow(unreachable_code)]
12755 fn try_from(value: FieldRef<'a>) -> ::planus::Result<Self> {
12756 ::core::result::Result::Ok(Self {
12757 name: value.name()?.map(::core::convert::Into::into),
12758 nullable: ::core::convert::TryInto::try_into(value.nullable()?)?,
12759 type_: if let ::core::option::Option::Some(type_) = value.type_()? {
12760 ::core::option::Option::Some(
12761 ::core::convert::TryInto::try_into(type_)?,
12762 )
12763 } else {
12764 ::core::option::Option::None
12765 },
12766 dictionary: if let ::core::option::Option::Some(dictionary) =
12767 value.dictionary()?
12768 {
12769 ::core::option::Option::Some(::planus::alloc::boxed::Box::new(
12770 ::core::convert::TryInto::try_into(dictionary)?,
12771 ))
12772 } else {
12773 ::core::option::Option::None
12774 },
12775 children: if let ::core::option::Option::Some(children) =
12776 value.children()?
12777 {
12778 ::core::option::Option::Some(children.to_vec_result()?)
12779 } else {
12780 ::core::option::Option::None
12781 },
12782 custom_metadata: if let ::core::option::Option::Some(
12783 custom_metadata,
12784 ) = value.custom_metadata()?
12785 {
12786 ::core::option::Option::Some(custom_metadata.to_vec_result()?)
12787 } else {
12788 ::core::option::Option::None
12789 },
12790 })
12791 }
12792 }
12793
12794 impl<'a> ::planus::TableRead<'a> for FieldRef<'a> {
12795 #[inline]
12796 fn from_buffer(
12797 buffer: ::planus::SliceWithStartOffset<'a>,
12798 offset: usize,
12799 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
12800 {
12801 ::core::result::Result::Ok(Self(
12802 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
12803 ))
12804 }
12805 }
12806
12807 impl<'a> ::planus::VectorReadInner<'a> for FieldRef<'a> {
12808 type Error = ::planus::Error;
12809 const STRIDE: usize = 4;
12810
12811 unsafe fn from_buffer(
12812 buffer: ::planus::SliceWithStartOffset<'a>,
12813 offset: usize,
12814 ) -> ::planus::Result<Self> {
12815 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
12816 error_kind.with_error_location(
12817 "[FieldRef]",
12818 "get",
12819 buffer.offset_from_start,
12820 )
12821 })
12822 }
12823 }
12824
12825 /// # Safety
12826 /// The planus compiler generates implementations that initialize
12827 /// the bytes in `write_values`.
12828 unsafe impl ::planus::VectorWrite<::planus::Offset<Field>> for Field {
12829 type Value = ::planus::Offset<Field>;
12830 const STRIDE: usize = 4;
12831 #[inline]
12832 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
12833 ::planus::WriteAs::prepare(self, builder)
12834 }
12835
12836 #[inline]
12837 unsafe fn write_values(
12838 values: &[::planus::Offset<Field>],
12839 bytes: *mut ::core::mem::MaybeUninit<u8>,
12840 buffer_position: u32,
12841 ) {
12842 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
12843 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
12844 ::planus::WriteAsPrimitive::write(
12845 v,
12846 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
12847 buffer_position - (Self::STRIDE * i) as u32,
12848 );
12849 }
12850 }
12851 }
12852
12853 impl<'a> ::planus::ReadAsRoot<'a> for FieldRef<'a> {
12854 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
12855 ::planus::TableRead::from_buffer(
12856 ::planus::SliceWithStartOffset {
12857 buffer: slice,
12858 offset_from_start: 0,
12859 },
12860 0,
12861 )
12862 .map_err(|error_kind| {
12863 error_kind.with_error_location("[FieldRef]", "read_as_root", 0)
12864 })
12865 }
12866 }
12867
12868 /// ----------------------------------------------------------------------
12869 /// Endianness of the platform producing the data
12870 ///
12871 /// Generated from these locations:
12872 /// * Enum `Endianness` in the file `Schema.fbs:536`
12873 #[derive(
12874 Copy,
12875 Clone,
12876 Debug,
12877 PartialEq,
12878 Eq,
12879 PartialOrd,
12880 Ord,
12881 Hash,
12882 ::serde::Serialize,
12883 ::serde::Deserialize,
12884 )]
12885 #[repr(i16)]
12886 pub enum Endianness {
12887 /// The variant `Little` in the enum `Endianness`
12888 Little = 0,
12889
12890 /// The variant `Big` in the enum `Endianness`
12891 Big = 1,
12892 }
12893
12894 impl Endianness {
12895 /// Array containing all valid variants of Endianness
12896 pub const ENUM_VALUES: [Self; 2] = [Self::Little, Self::Big];
12897 }
12898
12899 impl ::core::convert::TryFrom<i16> for Endianness {
12900 type Error = ::planus::errors::UnknownEnumTagKind;
12901 #[inline]
12902 fn try_from(
12903 value: i16,
12904 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
12905 {
12906 #[allow(clippy::match_single_binding)]
12907 match value {
12908 0 => ::core::result::Result::Ok(Endianness::Little),
12909 1 => ::core::result::Result::Ok(Endianness::Big),
12910
12911 _ => ::core::result::Result::Err(
12912 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
12913 ),
12914 }
12915 }
12916 }
12917
12918 impl ::core::convert::From<Endianness> for i16 {
12919 #[inline]
12920 fn from(value: Endianness) -> Self {
12921 value as i16
12922 }
12923 }
12924
12925 /// # Safety
12926 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
12927 unsafe impl ::planus::Primitive for Endianness {
12928 const ALIGNMENT: usize = 2;
12929 const SIZE: usize = 2;
12930 }
12931
12932 impl ::planus::WriteAsPrimitive<Endianness> for Endianness {
12933 #[inline]
12934 fn write<const N: usize>(
12935 &self,
12936 cursor: ::planus::Cursor<'_, N>,
12937 buffer_position: u32,
12938 ) {
12939 (*self as i16).write(cursor, buffer_position);
12940 }
12941 }
12942
12943 impl ::planus::WriteAs<Endianness> for Endianness {
12944 type Prepared = Self;
12945
12946 #[inline]
12947 fn prepare(&self, _builder: &mut ::planus::Builder) -> Endianness {
12948 *self
12949 }
12950 }
12951
12952 impl ::planus::WriteAsDefault<Endianness, Endianness> for Endianness {
12953 type Prepared = Self;
12954
12955 #[inline]
12956 fn prepare(
12957 &self,
12958 _builder: &mut ::planus::Builder,
12959 default: &Endianness,
12960 ) -> ::core::option::Option<Endianness> {
12961 if self == default {
12962 ::core::option::Option::None
12963 } else {
12964 ::core::option::Option::Some(*self)
12965 }
12966 }
12967 }
12968
12969 impl ::planus::WriteAsOptional<Endianness> for Endianness {
12970 type Prepared = Self;
12971
12972 #[inline]
12973 fn prepare(
12974 &self,
12975 _builder: &mut ::planus::Builder,
12976 ) -> ::core::option::Option<Endianness> {
12977 ::core::option::Option::Some(*self)
12978 }
12979 }
12980
12981 impl<'buf> ::planus::TableRead<'buf> for Endianness {
12982 #[inline]
12983 fn from_buffer(
12984 buffer: ::planus::SliceWithStartOffset<'buf>,
12985 offset: usize,
12986 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
12987 {
12988 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
12989 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
12990 }
12991 }
12992
12993 impl<'buf> ::planus::VectorReadInner<'buf> for Endianness {
12994 type Error = ::planus::errors::UnknownEnumTag;
12995 const STRIDE: usize = 2;
12996 #[inline]
12997 unsafe fn from_buffer(
12998 buffer: ::planus::SliceWithStartOffset<'buf>,
12999 offset: usize,
13000 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
13001 {
13002 let value = unsafe {
13003 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
13004 };
13005 let value: ::core::result::Result<Self, _> =
13006 ::core::convert::TryInto::try_into(value);
13007 value.map_err(|error_kind| {
13008 error_kind.with_error_location(
13009 "Endianness",
13010 "VectorRead::from_buffer",
13011 buffer.offset_from_start,
13012 )
13013 })
13014 }
13015 }
13016
13017 /// # Safety
13018 /// The planus compiler generates implementations that initialize
13019 /// the bytes in `write_values`.
13020 unsafe impl ::planus::VectorWrite<Endianness> for Endianness {
13021 const STRIDE: usize = 2;
13022
13023 type Value = Self;
13024
13025 #[inline]
13026 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
13027 *self
13028 }
13029
13030 #[inline]
13031 unsafe fn write_values(
13032 values: &[Self],
13033 bytes: *mut ::core::mem::MaybeUninit<u8>,
13034 buffer_position: u32,
13035 ) {
13036 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
13037 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
13038 ::planus::WriteAsPrimitive::write(
13039 v,
13040 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
13041 buffer_position - (2 * i) as u32,
13042 );
13043 }
13044 }
13045 }
13046
13047 /// ----------------------------------------------------------------------
13048 /// A Buffer represents a single contiguous memory segment
13049 ///
13050 /// Generated from these locations:
13051 /// * Struct `Buffer` in the file `Schema.fbs:540`
13052 #[derive(
13053 Copy,
13054 Clone,
13055 Debug,
13056 PartialEq,
13057 PartialOrd,
13058 Eq,
13059 Ord,
13060 Hash,
13061 Default,
13062 ::serde::Serialize,
13063 ::serde::Deserialize,
13064 )]
13065 pub struct Buffer {
13066 /// The relative offset into the shared memory page where the bytes for this
13067 /// buffer starts
13068 pub offset: i64,
13069
13070 /// The absolute length (in bytes) of the memory buffer. The memory is found
13071 /// from offset (inclusive) to offset + length (non-inclusive). When building
13072 /// messages using the encapsulated IPC message, padding bytes may be written
13073 /// after a buffer, but such padding bytes do not need to be accounted for in
13074 /// the size here.
13075 pub length: i64,
13076 }
13077
13078 /// # Safety
13079 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
13080 unsafe impl ::planus::Primitive for Buffer {
13081 const ALIGNMENT: usize = 8;
13082 const SIZE: usize = 16;
13083 }
13084
13085 #[allow(clippy::identity_op)]
13086 impl ::planus::WriteAsPrimitive<Buffer> for Buffer {
13087 #[inline]
13088 fn write<const N: usize>(
13089 &self,
13090 cursor: ::planus::Cursor<'_, N>,
13091 buffer_position: u32,
13092 ) {
13093 let (cur, cursor) = cursor.split::<8, 8>();
13094 self.offset.write(cur, buffer_position - 0);
13095 let (cur, cursor) = cursor.split::<8, 0>();
13096 self.length.write(cur, buffer_position - 8);
13097 cursor.finish([]);
13098 }
13099 }
13100
13101 impl ::planus::WriteAsOffset<Buffer> for Buffer {
13102 #[inline]
13103 fn prepare(
13104 &self,
13105 builder: &mut ::planus::Builder,
13106 ) -> ::planus::Offset<Buffer> {
13107 unsafe {
13108 builder.write_with(16, 7, |buffer_position, bytes| {
13109 let bytes = bytes.as_mut_ptr();
13110
13111 ::planus::WriteAsPrimitive::write(
13112 self,
13113 ::planus::Cursor::new(
13114 &mut *(bytes
13115 as *mut [::core::mem::MaybeUninit<u8>; 16]),
13116 ),
13117 buffer_position,
13118 );
13119 });
13120 }
13121 builder.current_offset()
13122 }
13123 }
13124
13125 impl ::planus::WriteAs<Buffer> for Buffer {
13126 type Prepared = Self;
13127 #[inline]
13128 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
13129 *self
13130 }
13131 }
13132
13133 impl ::planus::WriteAsOptional<Buffer> for Buffer {
13134 type Prepared = Self;
13135 #[inline]
13136 fn prepare(
13137 &self,
13138 _builder: &mut ::planus::Builder,
13139 ) -> ::core::option::Option<Self> {
13140 ::core::option::Option::Some(*self)
13141 }
13142 }
13143
13144 /// Reference to a deserialized [Buffer].
13145 #[derive(Copy, Clone)]
13146 pub struct BufferRef<'a>(::planus::ArrayWithStartOffset<'a, 16>);
13147
13148 impl<'a> BufferRef<'a> {
13149 /// Getter for the [`offset` field](Buffer#structfield.offset).
13150 pub fn offset(&self) -> i64 {
13151 let buffer = self.0.advance_as_array::<8>(0).unwrap();
13152
13153 i64::from_le_bytes(*buffer.as_array())
13154 }
13155
13156 /// Getter for the [`length` field](Buffer#structfield.length).
13157 pub fn length(&self) -> i64 {
13158 let buffer = self.0.advance_as_array::<8>(8).unwrap();
13159
13160 i64::from_le_bytes(*buffer.as_array())
13161 }
13162 }
13163
13164 impl<'a> ::core::fmt::Debug for BufferRef<'a> {
13165 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
13166 let mut f = f.debug_struct("BufferRef");
13167 f.field("offset", &self.offset());
13168 f.field("length", &self.length());
13169 f.finish()
13170 }
13171 }
13172
13173 impl<'a> ::core::convert::From<::planus::ArrayWithStartOffset<'a, 16>> for BufferRef<'a> {
13174 fn from(array: ::planus::ArrayWithStartOffset<'a, 16>) -> Self {
13175 Self(array)
13176 }
13177 }
13178
13179 impl<'a> ::core::convert::From<BufferRef<'a>> for Buffer {
13180 #[allow(unreachable_code)]
13181 fn from(value: BufferRef<'a>) -> Self {
13182 Self {
13183 offset: value.offset(),
13184 length: value.length(),
13185 }
13186 }
13187 }
13188
13189 impl<'a, 'b> ::core::cmp::PartialEq<BufferRef<'a>> for BufferRef<'b> {
13190 fn eq(&self, other: &BufferRef<'_>) -> bool {
13191 self.offset() == other.offset() && self.length() == other.length()
13192 }
13193 }
13194
13195 impl<'a> ::core::cmp::Eq for BufferRef<'a> {}
13196 impl<'a, 'b> ::core::cmp::PartialOrd<BufferRef<'a>> for BufferRef<'b> {
13197 fn partial_cmp(
13198 &self,
13199 other: &BufferRef<'_>,
13200 ) -> ::core::option::Option<::core::cmp::Ordering> {
13201 ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
13202 }
13203 }
13204
13205 impl<'a> ::core::cmp::Ord for BufferRef<'a> {
13206 fn cmp(&self, other: &BufferRef<'_>) -> ::core::cmp::Ordering {
13207 self.offset()
13208 .cmp(&other.offset())
13209 .then_with(|| self.length().cmp(&other.length()))
13210 }
13211 }
13212
13213 impl<'a> ::core::hash::Hash for BufferRef<'a> {
13214 fn hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
13215 self.offset().hash(state);
13216 self.length().hash(state);
13217 }
13218 }
13219
13220 impl<'a> ::planus::TableRead<'a> for BufferRef<'a> {
13221 #[inline]
13222 fn from_buffer(
13223 buffer: ::planus::SliceWithStartOffset<'a>,
13224 offset: usize,
13225 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
13226 {
13227 let buffer = buffer.advance_as_array::<16>(offset)?;
13228 ::core::result::Result::Ok(Self(buffer))
13229 }
13230 }
13231
13232 impl<'a> ::planus::VectorRead<'a> for BufferRef<'a> {
13233 const STRIDE: usize = 16;
13234
13235 #[inline]
13236 unsafe fn from_buffer(
13237 buffer: ::planus::SliceWithStartOffset<'a>,
13238 offset: usize,
13239 ) -> Self {
13240 Self(unsafe { buffer.unchecked_advance_as_array(offset) })
13241 }
13242 }
13243
13244 /// # Safety
13245 /// The planus compiler generates implementations that initialize
13246 /// the bytes in `write_values`.
13247 unsafe impl ::planus::VectorWrite<Buffer> for Buffer {
13248 const STRIDE: usize = 16;
13249
13250 type Value = Buffer;
13251
13252 #[inline]
13253 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self::Value {
13254 *self
13255 }
13256
13257 #[inline]
13258 unsafe fn write_values(
13259 values: &[Buffer],
13260 bytes: *mut ::core::mem::MaybeUninit<u8>,
13261 buffer_position: u32,
13262 ) {
13263 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 16];
13264 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
13265 ::planus::WriteAsPrimitive::write(
13266 v,
13267 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
13268 buffer_position - (16 * i) as u32,
13269 );
13270 }
13271 }
13272 }
13273
13274 /// ----------------------------------------------------------------------
13275 /// A Schema describes the columns in a row batch
13276 ///
13277 /// Generated from these locations:
13278 /// * Table `Schema` in the file `Schema.fbs:556`
13279 #[derive(
13280 Clone,
13281 Debug,
13282 PartialEq,
13283 PartialOrd,
13284 Eq,
13285 Ord,
13286 Hash,
13287 ::serde::Serialize,
13288 ::serde::Deserialize,
13289 )]
13290 pub struct Schema {
13291 /// endianness of the buffer
13292 /// it is Little Endian by default
13293 /// if endianness doesn't match the underlying system then the vectors need to be converted
13294 pub endianness: self::Endianness,
13295 /// The field `fields` in the table `Schema`
13296 pub fields: ::core::option::Option<::planus::alloc::vec::Vec<self::Field>>,
13297 /// The field `custom_metadata` in the table `Schema`
13298 pub custom_metadata:
13299 ::core::option::Option<::planus::alloc::vec::Vec<self::KeyValue>>,
13300 /// Features used in the stream/file.
13301 pub features:
13302 ::core::option::Option<::planus::alloc::vec::Vec<self::Feature>>,
13303 }
13304
13305 #[allow(clippy::derivable_impls)]
13306 impl ::core::default::Default for Schema {
13307 fn default() -> Self {
13308 Self {
13309 endianness: self::Endianness::Little,
13310 fields: ::core::default::Default::default(),
13311 custom_metadata: ::core::default::Default::default(),
13312 features: ::core::default::Default::default(),
13313 }
13314 }
13315 }
13316
13317 impl Schema {
13318 /// Creates a [SchemaBuilder] for serializing an instance of this table.
13319 #[inline]
13320 pub fn builder() -> SchemaBuilder<()> {
13321 SchemaBuilder(())
13322 }
13323
13324 #[allow(clippy::too_many_arguments)]
13325 pub fn create(
13326 builder: &mut ::planus::Builder,
13327 field_endianness: impl ::planus::WriteAsDefault<
13328 self::Endianness,
13329 self::Endianness,
13330 >,
13331 field_fields: impl ::planus::WriteAsOptional<
13332 ::planus::Offset<[::planus::Offset<self::Field>]>,
13333 >,
13334 field_custom_metadata: impl ::planus::WriteAsOptional<
13335 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
13336 >,
13337 field_features: impl ::planus::WriteAsOptional<
13338 ::planus::Offset<[self::Feature]>,
13339 >,
13340 ) -> ::planus::Offset<Self> {
13341 let prepared_endianness =
13342 field_endianness.prepare(builder, &self::Endianness::Little);
13343 let prepared_fields = field_fields.prepare(builder);
13344 let prepared_custom_metadata = field_custom_metadata.prepare(builder);
13345 let prepared_features = field_features.prepare(builder);
13346
13347 let mut table_writer: ::planus::table_writer::TableWriter<12> =
13348 ::core::default::Default::default();
13349 if prepared_fields.is_some() {
13350 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::Field>]>>(1);
13351 }
13352 if prepared_custom_metadata.is_some() {
13353 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::KeyValue>]>>(2);
13354 }
13355 if prepared_features.is_some() {
13356 table_writer.write_entry::<::planus::Offset<[self::Feature]>>(3);
13357 }
13358 if prepared_endianness.is_some() {
13359 table_writer.write_entry::<self::Endianness>(0);
13360 }
13361
13362 unsafe {
13363 table_writer.finish(builder, |object_writer| {
13364 if let ::core::option::Option::Some(prepared_fields) =
13365 prepared_fields
13366 {
13367 object_writer.write::<_, _, 4>(&prepared_fields);
13368 }
13369 if let ::core::option::Option::Some(prepared_custom_metadata) =
13370 prepared_custom_metadata
13371 {
13372 object_writer.write::<_, _, 4>(&prepared_custom_metadata);
13373 }
13374 if let ::core::option::Option::Some(prepared_features) =
13375 prepared_features
13376 {
13377 object_writer.write::<_, _, 4>(&prepared_features);
13378 }
13379 if let ::core::option::Option::Some(prepared_endianness) =
13380 prepared_endianness
13381 {
13382 object_writer.write::<_, _, 2>(&prepared_endianness);
13383 }
13384 });
13385 }
13386 builder.current_offset()
13387 }
13388 }
13389
13390 impl ::planus::WriteAs<::planus::Offset<Schema>> for Schema {
13391 type Prepared = ::planus::Offset<Self>;
13392
13393 #[inline]
13394 fn prepare(
13395 &self,
13396 builder: &mut ::planus::Builder,
13397 ) -> ::planus::Offset<Schema> {
13398 ::planus::WriteAsOffset::prepare(self, builder)
13399 }
13400 }
13401
13402 impl ::planus::WriteAsOptional<::planus::Offset<Schema>> for Schema {
13403 type Prepared = ::planus::Offset<Self>;
13404
13405 #[inline]
13406 fn prepare(
13407 &self,
13408 builder: &mut ::planus::Builder,
13409 ) -> ::core::option::Option<::planus::Offset<Schema>>
13410 {
13411 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
13412 self, builder,
13413 ))
13414 }
13415 }
13416
13417 impl ::planus::WriteAsOffset<Schema> for Schema {
13418 #[inline]
13419 fn prepare(
13420 &self,
13421 builder: &mut ::planus::Builder,
13422 ) -> ::planus::Offset<Schema> {
13423 Schema::create(
13424 builder,
13425 self.endianness,
13426 &self.fields,
13427 &self.custom_metadata,
13428 &self.features,
13429 )
13430 }
13431 }
13432
13433 /// Builder for serializing an instance of the [Schema] type.
13434 ///
13435 /// Can be created using the [Schema::builder] method.
13436 #[derive(Debug)]
13437 #[must_use]
13438 pub struct SchemaBuilder<State>(State);
13439
13440 impl SchemaBuilder<()> {
13441 /// Setter for the [`endianness` field](Schema#structfield.endianness).
13442 #[inline]
13443 #[allow(clippy::type_complexity)]
13444 pub fn endianness<T0>(self, value: T0) -> SchemaBuilder<(T0,)>
13445 where
13446 T0: ::planus::WriteAsDefault<self::Endianness, self::Endianness>,
13447 {
13448 SchemaBuilder((value,))
13449 }
13450
13451 /// Sets the [`endianness` field](Schema#structfield.endianness) to the default value.
13452 #[inline]
13453 #[allow(clippy::type_complexity)]
13454 pub fn endianness_as_default(
13455 self,
13456 ) -> SchemaBuilder<(::planus::DefaultValue,)> {
13457 self.endianness(::planus::DefaultValue)
13458 }
13459 }
13460
13461 impl<T0> SchemaBuilder<(T0,)> {
13462 /// Setter for the [`fields` field](Schema#structfield.fields).
13463 #[inline]
13464 #[allow(clippy::type_complexity)]
13465 pub fn fields<T1>(self, value: T1) -> SchemaBuilder<(T0, T1)>
13466 where
13467 T1: ::planus::WriteAsOptional<
13468 ::planus::Offset<[::planus::Offset<self::Field>]>,
13469 >,
13470 {
13471 let (v0,) = self.0;
13472 SchemaBuilder((v0, value))
13473 }
13474
13475 /// Sets the [`fields` field](Schema#structfield.fields) to null.
13476 #[inline]
13477 #[allow(clippy::type_complexity)]
13478 pub fn fields_as_null(self) -> SchemaBuilder<(T0, ())> {
13479 self.fields(())
13480 }
13481 }
13482
13483 impl<T0, T1> SchemaBuilder<(T0, T1)> {
13484 /// Setter for the [`custom_metadata` field](Schema#structfield.custom_metadata).
13485 #[inline]
13486 #[allow(clippy::type_complexity)]
13487 pub fn custom_metadata<T2>(self, value: T2) -> SchemaBuilder<(T0, T1, T2)>
13488 where
13489 T2: ::planus::WriteAsOptional<
13490 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
13491 >,
13492 {
13493 let (v0, v1) = self.0;
13494 SchemaBuilder((v0, v1, value))
13495 }
13496
13497 /// Sets the [`custom_metadata` field](Schema#structfield.custom_metadata) to null.
13498 #[inline]
13499 #[allow(clippy::type_complexity)]
13500 pub fn custom_metadata_as_null(self) -> SchemaBuilder<(T0, T1, ())> {
13501 self.custom_metadata(())
13502 }
13503 }
13504
13505 impl<T0, T1, T2> SchemaBuilder<(T0, T1, T2)> {
13506 /// Setter for the [`features` field](Schema#structfield.features).
13507 #[inline]
13508 #[allow(clippy::type_complexity)]
13509 pub fn features<T3>(self, value: T3) -> SchemaBuilder<(T0, T1, T2, T3)>
13510 where
13511 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Feature]>>,
13512 {
13513 let (v0, v1, v2) = self.0;
13514 SchemaBuilder((v0, v1, v2, value))
13515 }
13516
13517 /// Sets the [`features` field](Schema#structfield.features) to null.
13518 #[inline]
13519 #[allow(clippy::type_complexity)]
13520 pub fn features_as_null(self) -> SchemaBuilder<(T0, T1, T2, ())> {
13521 self.features(())
13522 }
13523 }
13524
13525 impl<T0, T1, T2, T3> SchemaBuilder<(T0, T1, T2, T3)> {
13526 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Schema].
13527 #[inline]
13528 pub fn finish(
13529 self,
13530 builder: &mut ::planus::Builder,
13531 ) -> ::planus::Offset<Schema>
13532 where
13533 Self: ::planus::WriteAsOffset<Schema>,
13534 {
13535 ::planus::WriteAsOffset::prepare(&self, builder)
13536 }
13537 }
13538
13539 impl<
13540 T0: ::planus::WriteAsDefault<self::Endianness, self::Endianness>,
13541 T1: ::planus::WriteAsOptional<
13542 ::planus::Offset<[::planus::Offset<self::Field>]>,
13543 >,
13544 T2: ::planus::WriteAsOptional<
13545 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
13546 >,
13547 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Feature]>>,
13548 > ::planus::WriteAs<::planus::Offset<Schema>>
13549 for SchemaBuilder<(T0, T1, T2, T3)>
13550 {
13551 type Prepared = ::planus::Offset<Schema>;
13552
13553 #[inline]
13554 fn prepare(
13555 &self,
13556 builder: &mut ::planus::Builder,
13557 ) -> ::planus::Offset<Schema> {
13558 ::planus::WriteAsOffset::prepare(self, builder)
13559 }
13560 }
13561
13562 impl<
13563 T0: ::planus::WriteAsDefault<self::Endianness, self::Endianness>,
13564 T1: ::planus::WriteAsOptional<
13565 ::planus::Offset<[::planus::Offset<self::Field>]>,
13566 >,
13567 T2: ::planus::WriteAsOptional<
13568 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
13569 >,
13570 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Feature]>>,
13571 > ::planus::WriteAsOptional<::planus::Offset<Schema>>
13572 for SchemaBuilder<(T0, T1, T2, T3)>
13573 {
13574 type Prepared = ::planus::Offset<Schema>;
13575
13576 #[inline]
13577 fn prepare(
13578 &self,
13579 builder: &mut ::planus::Builder,
13580 ) -> ::core::option::Option<::planus::Offset<Schema>>
13581 {
13582 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
13583 self, builder,
13584 ))
13585 }
13586 }
13587
13588 impl<
13589 T0: ::planus::WriteAsDefault<self::Endianness, self::Endianness>,
13590 T1: ::planus::WriteAsOptional<
13591 ::planus::Offset<[::planus::Offset<self::Field>]>,
13592 >,
13593 T2: ::planus::WriteAsOptional<
13594 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
13595 >,
13596 T3: ::planus::WriteAsOptional<::planus::Offset<[self::Feature]>>,
13597 > ::planus::WriteAsOffset<Schema> for SchemaBuilder<(T0, T1, T2, T3)>
13598 {
13599 #[inline]
13600 fn prepare(
13601 &self,
13602 builder: &mut ::planus::Builder,
13603 ) -> ::planus::Offset<Schema> {
13604 let (v0, v1, v2, v3) = &self.0;
13605 Schema::create(builder, v0, v1, v2, v3)
13606 }
13607 }
13608
13609 /// Reference to a deserialized [Schema].
13610 #[derive(Copy, Clone)]
13611 pub struct SchemaRef<'a>(::planus::table_reader::Table<'a>);
13612
13613 impl<'a> SchemaRef<'a> {
13614 /// Getter for the [`endianness` field](Schema#structfield.endianness).
13615 #[inline]
13616 pub fn endianness(&self) -> ::planus::Result<self::Endianness> {
13617 ::core::result::Result::Ok(
13618 self.0
13619 .access(0, "Schema", "endianness")?
13620 .unwrap_or(self::Endianness::Little),
13621 )
13622 }
13623
13624 /// Getter for the [`fields` field](Schema#structfield.fields).
13625 #[inline]
13626 pub fn fields(
13627 &self,
13628 ) -> ::planus::Result<
13629 ::core::option::Option<
13630 ::planus::Vector<'a, ::planus::Result<self::FieldRef<'a>>>,
13631 >,
13632 > {
13633 self.0.access(1, "Schema", "fields")
13634 }
13635
13636 /// Getter for the [`custom_metadata` field](Schema#structfield.custom_metadata).
13637 #[inline]
13638 pub fn custom_metadata(
13639 &self,
13640 ) -> ::planus::Result<
13641 ::core::option::Option<
13642 ::planus::Vector<'a, ::planus::Result<self::KeyValueRef<'a>>>,
13643 >,
13644 > {
13645 self.0.access(2, "Schema", "custom_metadata")
13646 }
13647
13648 /// Getter for the [`features` field](Schema#structfield.features).
13649 #[inline]
13650 pub fn features(
13651 &self,
13652 ) -> ::planus::Result<
13653 ::core::option::Option<
13654 ::planus::Vector<
13655 'a,
13656 ::core::result::Result<
13657 self::Feature,
13658 ::planus::errors::UnknownEnumTag,
13659 >,
13660 >,
13661 >,
13662 > {
13663 self.0.access(3, "Schema", "features")
13664 }
13665 }
13666
13667 impl<'a> ::core::fmt::Debug for SchemaRef<'a> {
13668 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
13669 let mut f = f.debug_struct("SchemaRef");
13670 f.field("endianness", &self.endianness());
13671 if let ::core::option::Option::Some(field_fields) =
13672 self.fields().transpose()
13673 {
13674 f.field("fields", &field_fields);
13675 }
13676 if let ::core::option::Option::Some(field_custom_metadata) =
13677 self.custom_metadata().transpose()
13678 {
13679 f.field("custom_metadata", &field_custom_metadata);
13680 }
13681 if let ::core::option::Option::Some(field_features) =
13682 self.features().transpose()
13683 {
13684 f.field("features", &field_features);
13685 }
13686 f.finish()
13687 }
13688 }
13689
13690 impl<'a> ::core::convert::TryFrom<SchemaRef<'a>> for Schema {
13691 type Error = ::planus::Error;
13692
13693 #[allow(unreachable_code)]
13694 fn try_from(value: SchemaRef<'a>) -> ::planus::Result<Self> {
13695 ::core::result::Result::Ok(Self {
13696 endianness: ::core::convert::TryInto::try_into(
13697 value.endianness()?,
13698 )?,
13699 fields: if let ::core::option::Option::Some(fields) =
13700 value.fields()?
13701 {
13702 ::core::option::Option::Some(fields.to_vec_result()?)
13703 } else {
13704 ::core::option::Option::None
13705 },
13706 custom_metadata: if let ::core::option::Option::Some(
13707 custom_metadata,
13708 ) = value.custom_metadata()?
13709 {
13710 ::core::option::Option::Some(custom_metadata.to_vec_result()?)
13711 } else {
13712 ::core::option::Option::None
13713 },
13714 features: if let ::core::option::Option::Some(features) =
13715 value.features()?
13716 {
13717 ::core::option::Option::Some(features.to_vec_result()?)
13718 } else {
13719 ::core::option::Option::None
13720 },
13721 })
13722 }
13723 }
13724
13725 impl<'a> ::planus::TableRead<'a> for SchemaRef<'a> {
13726 #[inline]
13727 fn from_buffer(
13728 buffer: ::planus::SliceWithStartOffset<'a>,
13729 offset: usize,
13730 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
13731 {
13732 ::core::result::Result::Ok(Self(
13733 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
13734 ))
13735 }
13736 }
13737
13738 impl<'a> ::planus::VectorReadInner<'a> for SchemaRef<'a> {
13739 type Error = ::planus::Error;
13740 const STRIDE: usize = 4;
13741
13742 unsafe fn from_buffer(
13743 buffer: ::planus::SliceWithStartOffset<'a>,
13744 offset: usize,
13745 ) -> ::planus::Result<Self> {
13746 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
13747 error_kind.with_error_location(
13748 "[SchemaRef]",
13749 "get",
13750 buffer.offset_from_start,
13751 )
13752 })
13753 }
13754 }
13755
13756 /// # Safety
13757 /// The planus compiler generates implementations that initialize
13758 /// the bytes in `write_values`.
13759 unsafe impl ::planus::VectorWrite<::planus::Offset<Schema>> for Schema {
13760 type Value = ::planus::Offset<Schema>;
13761 const STRIDE: usize = 4;
13762 #[inline]
13763 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
13764 ::planus::WriteAs::prepare(self, builder)
13765 }
13766
13767 #[inline]
13768 unsafe fn write_values(
13769 values: &[::planus::Offset<Schema>],
13770 bytes: *mut ::core::mem::MaybeUninit<u8>,
13771 buffer_position: u32,
13772 ) {
13773 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
13774 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
13775 ::planus::WriteAsPrimitive::write(
13776 v,
13777 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
13778 buffer_position - (Self::STRIDE * i) as u32,
13779 );
13780 }
13781 }
13782 }
13783
13784 impl<'a> ::planus::ReadAsRoot<'a> for SchemaRef<'a> {
13785 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
13786 ::planus::TableRead::from_buffer(
13787 ::planus::SliceWithStartOffset {
13788 buffer: slice,
13789 offset_from_start: 0,
13790 },
13791 0,
13792 )
13793 .map_err(|error_kind| {
13794 error_kind.with_error_location("[SchemaRef]", "read_as_root", 0)
13795 })
13796 }
13797 }
13798
13799 /// ----------------------------------------------------------------------
13800 /// Data structures for describing a table row batch (a collection of
13801 /// equal-length Arrow arrays)
13802 /// Metadata about a field at some level of a nested type tree (but not
13803 /// its children).
13804 ///
13805 /// For example, a List<Int16> with values `[[1, 2, 3], null, [4], [5, 6], null]`
13806 /// would have {length: 5, null_count: 2} for its List node, and {length: 6,
13807 /// null_count: 0} for its Int16 node, as separate FieldNode structs
13808 ///
13809 /// Generated from these locations:
13810 /// * Struct `FieldNode` in the file `Message.fbs:34`
13811 #[derive(
13812 Copy,
13813 Clone,
13814 Debug,
13815 PartialEq,
13816 PartialOrd,
13817 Eq,
13818 Ord,
13819 Hash,
13820 Default,
13821 ::serde::Serialize,
13822 ::serde::Deserialize,
13823 )]
13824 pub struct FieldNode {
13825 /// The number of value slots in the Arrow array at this level of a nested
13826 /// tree
13827 pub length: i64,
13828
13829 /// The number of observed nulls. Fields with null_count == 0 may choose not
13830 /// to write their physical validity bitmap out as a materialized buffer,
13831 /// instead setting the length of the bitmap buffer to 0.
13832 pub null_count: i64,
13833 }
13834
13835 /// # Safety
13836 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
13837 unsafe impl ::planus::Primitive for FieldNode {
13838 const ALIGNMENT: usize = 8;
13839 const SIZE: usize = 16;
13840 }
13841
13842 #[allow(clippy::identity_op)]
13843 impl ::planus::WriteAsPrimitive<FieldNode> for FieldNode {
13844 #[inline]
13845 fn write<const N: usize>(
13846 &self,
13847 cursor: ::planus::Cursor<'_, N>,
13848 buffer_position: u32,
13849 ) {
13850 let (cur, cursor) = cursor.split::<8, 8>();
13851 self.length.write(cur, buffer_position - 0);
13852 let (cur, cursor) = cursor.split::<8, 0>();
13853 self.null_count.write(cur, buffer_position - 8);
13854 cursor.finish([]);
13855 }
13856 }
13857
13858 impl ::planus::WriteAsOffset<FieldNode> for FieldNode {
13859 #[inline]
13860 fn prepare(
13861 &self,
13862 builder: &mut ::planus::Builder,
13863 ) -> ::planus::Offset<FieldNode> {
13864 unsafe {
13865 builder.write_with(16, 7, |buffer_position, bytes| {
13866 let bytes = bytes.as_mut_ptr();
13867
13868 ::planus::WriteAsPrimitive::write(
13869 self,
13870 ::planus::Cursor::new(
13871 &mut *(bytes
13872 as *mut [::core::mem::MaybeUninit<u8>; 16]),
13873 ),
13874 buffer_position,
13875 );
13876 });
13877 }
13878 builder.current_offset()
13879 }
13880 }
13881
13882 impl ::planus::WriteAs<FieldNode> for FieldNode {
13883 type Prepared = Self;
13884 #[inline]
13885 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
13886 *self
13887 }
13888 }
13889
13890 impl ::planus::WriteAsOptional<FieldNode> for FieldNode {
13891 type Prepared = Self;
13892 #[inline]
13893 fn prepare(
13894 &self,
13895 _builder: &mut ::planus::Builder,
13896 ) -> ::core::option::Option<Self> {
13897 ::core::option::Option::Some(*self)
13898 }
13899 }
13900
13901 /// Reference to a deserialized [FieldNode].
13902 #[derive(Copy, Clone)]
13903 pub struct FieldNodeRef<'a>(::planus::ArrayWithStartOffset<'a, 16>);
13904
13905 impl<'a> FieldNodeRef<'a> {
13906 /// Getter for the [`length` field](FieldNode#structfield.length).
13907 pub fn length(&self) -> i64 {
13908 let buffer = self.0.advance_as_array::<8>(0).unwrap();
13909
13910 i64::from_le_bytes(*buffer.as_array())
13911 }
13912
13913 /// Getter for the [`null_count` field](FieldNode#structfield.null_count).
13914 pub fn null_count(&self) -> i64 {
13915 let buffer = self.0.advance_as_array::<8>(8).unwrap();
13916
13917 i64::from_le_bytes(*buffer.as_array())
13918 }
13919 }
13920
13921 impl<'a> ::core::fmt::Debug for FieldNodeRef<'a> {
13922 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
13923 let mut f = f.debug_struct("FieldNodeRef");
13924 f.field("length", &self.length());
13925 f.field("null_count", &self.null_count());
13926 f.finish()
13927 }
13928 }
13929
13930 impl<'a> ::core::convert::From<::planus::ArrayWithStartOffset<'a, 16>> for FieldNodeRef<'a> {
13931 fn from(array: ::planus::ArrayWithStartOffset<'a, 16>) -> Self {
13932 Self(array)
13933 }
13934 }
13935
13936 impl<'a> ::core::convert::From<FieldNodeRef<'a>> for FieldNode {
13937 #[allow(unreachable_code)]
13938 fn from(value: FieldNodeRef<'a>) -> Self {
13939 Self {
13940 length: value.length(),
13941 null_count: value.null_count(),
13942 }
13943 }
13944 }
13945
13946 impl<'a, 'b> ::core::cmp::PartialEq<FieldNodeRef<'a>> for FieldNodeRef<'b> {
13947 fn eq(&self, other: &FieldNodeRef<'_>) -> bool {
13948 self.length() == other.length()
13949 && self.null_count() == other.null_count()
13950 }
13951 }
13952
13953 impl<'a> ::core::cmp::Eq for FieldNodeRef<'a> {}
13954 impl<'a, 'b> ::core::cmp::PartialOrd<FieldNodeRef<'a>> for FieldNodeRef<'b> {
13955 fn partial_cmp(
13956 &self,
13957 other: &FieldNodeRef<'_>,
13958 ) -> ::core::option::Option<::core::cmp::Ordering> {
13959 ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
13960 }
13961 }
13962
13963 impl<'a> ::core::cmp::Ord for FieldNodeRef<'a> {
13964 fn cmp(&self, other: &FieldNodeRef<'_>) -> ::core::cmp::Ordering {
13965 self.length()
13966 .cmp(&other.length())
13967 .then_with(|| self.null_count().cmp(&other.null_count()))
13968 }
13969 }
13970
13971 impl<'a> ::core::hash::Hash for FieldNodeRef<'a> {
13972 fn hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
13973 self.length().hash(state);
13974 self.null_count().hash(state);
13975 }
13976 }
13977
13978 impl<'a> ::planus::TableRead<'a> for FieldNodeRef<'a> {
13979 #[inline]
13980 fn from_buffer(
13981 buffer: ::planus::SliceWithStartOffset<'a>,
13982 offset: usize,
13983 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
13984 {
13985 let buffer = buffer.advance_as_array::<16>(offset)?;
13986 ::core::result::Result::Ok(Self(buffer))
13987 }
13988 }
13989
13990 impl<'a> ::planus::VectorRead<'a> for FieldNodeRef<'a> {
13991 const STRIDE: usize = 16;
13992
13993 #[inline]
13994 unsafe fn from_buffer(
13995 buffer: ::planus::SliceWithStartOffset<'a>,
13996 offset: usize,
13997 ) -> Self {
13998 Self(unsafe { buffer.unchecked_advance_as_array(offset) })
13999 }
14000 }
14001
14002 /// # Safety
14003 /// The planus compiler generates implementations that initialize
14004 /// the bytes in `write_values`.
14005 unsafe impl ::planus::VectorWrite<FieldNode> for FieldNode {
14006 const STRIDE: usize = 16;
14007
14008 type Value = FieldNode;
14009
14010 #[inline]
14011 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self::Value {
14012 *self
14013 }
14014
14015 #[inline]
14016 unsafe fn write_values(
14017 values: &[FieldNode],
14018 bytes: *mut ::core::mem::MaybeUninit<u8>,
14019 buffer_position: u32,
14020 ) {
14021 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 16];
14022 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
14023 ::planus::WriteAsPrimitive::write(
14024 v,
14025 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
14026 buffer_position - (16 * i) as u32,
14027 );
14028 }
14029 }
14030 }
14031
14032 /// The enum `CompressionType` in the namespace `org.apache.arrow.flatbuf`
14033 ///
14034 /// Generated from these locations:
14035 /// * Enum `CompressionType` in the file `Message.fbs:45`
14036 #[derive(
14037 Copy,
14038 Clone,
14039 Debug,
14040 PartialEq,
14041 Eq,
14042 PartialOrd,
14043 Ord,
14044 Hash,
14045 ::serde::Serialize,
14046 ::serde::Deserialize,
14047 )]
14048 #[repr(i8)]
14049 pub enum CompressionType {
14050 /// The variant `LZ4_FRAME` in the enum `CompressionType`
14051 Lz4Frame = 0,
14052
14053 /// The variant `ZSTD` in the enum `CompressionType`
14054 Zstd = 1,
14055 }
14056
14057 impl CompressionType {
14058 /// Array containing all valid variants of CompressionType
14059 pub const ENUM_VALUES: [Self; 2] = [Self::Lz4Frame, Self::Zstd];
14060 }
14061
14062 impl ::core::convert::TryFrom<i8> for CompressionType {
14063 type Error = ::planus::errors::UnknownEnumTagKind;
14064 #[inline]
14065 fn try_from(
14066 value: i8,
14067 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
14068 {
14069 #[allow(clippy::match_single_binding)]
14070 match value {
14071 0 => ::core::result::Result::Ok(CompressionType::Lz4Frame),
14072 1 => ::core::result::Result::Ok(CompressionType::Zstd),
14073
14074 _ => ::core::result::Result::Err(
14075 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
14076 ),
14077 }
14078 }
14079 }
14080
14081 impl ::core::convert::From<CompressionType> for i8 {
14082 #[inline]
14083 fn from(value: CompressionType) -> Self {
14084 value as i8
14085 }
14086 }
14087
14088 /// # Safety
14089 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
14090 unsafe impl ::planus::Primitive for CompressionType {
14091 const ALIGNMENT: usize = 1;
14092 const SIZE: usize = 1;
14093 }
14094
14095 impl ::planus::WriteAsPrimitive<CompressionType> for CompressionType {
14096 #[inline]
14097 fn write<const N: usize>(
14098 &self,
14099 cursor: ::planus::Cursor<'_, N>,
14100 buffer_position: u32,
14101 ) {
14102 (*self as i8).write(cursor, buffer_position);
14103 }
14104 }
14105
14106 impl ::planus::WriteAs<CompressionType> for CompressionType {
14107 type Prepared = Self;
14108
14109 #[inline]
14110 fn prepare(&self, _builder: &mut ::planus::Builder) -> CompressionType {
14111 *self
14112 }
14113 }
14114
14115 impl ::planus::WriteAsDefault<CompressionType, CompressionType> for CompressionType {
14116 type Prepared = Self;
14117
14118 #[inline]
14119 fn prepare(
14120 &self,
14121 _builder: &mut ::planus::Builder,
14122 default: &CompressionType,
14123 ) -> ::core::option::Option<CompressionType> {
14124 if self == default {
14125 ::core::option::Option::None
14126 } else {
14127 ::core::option::Option::Some(*self)
14128 }
14129 }
14130 }
14131
14132 impl ::planus::WriteAsOptional<CompressionType> for CompressionType {
14133 type Prepared = Self;
14134
14135 #[inline]
14136 fn prepare(
14137 &self,
14138 _builder: &mut ::planus::Builder,
14139 ) -> ::core::option::Option<CompressionType> {
14140 ::core::option::Option::Some(*self)
14141 }
14142 }
14143
14144 impl<'buf> ::planus::TableRead<'buf> for CompressionType {
14145 #[inline]
14146 fn from_buffer(
14147 buffer: ::planus::SliceWithStartOffset<'buf>,
14148 offset: usize,
14149 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
14150 {
14151 let n: i8 = ::planus::TableRead::from_buffer(buffer, offset)?;
14152 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
14153 }
14154 }
14155
14156 impl<'buf> ::planus::VectorReadInner<'buf> for CompressionType {
14157 type Error = ::planus::errors::UnknownEnumTag;
14158 const STRIDE: usize = 1;
14159 #[inline]
14160 unsafe fn from_buffer(
14161 buffer: ::planus::SliceWithStartOffset<'buf>,
14162 offset: usize,
14163 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
14164 {
14165 let value = unsafe { *buffer.buffer.get_unchecked(offset) as i8 };
14166 let value: ::core::result::Result<Self, _> =
14167 ::core::convert::TryInto::try_into(value);
14168 value.map_err(|error_kind| {
14169 error_kind.with_error_location(
14170 "CompressionType",
14171 "VectorRead::from_buffer",
14172 buffer.offset_from_start,
14173 )
14174 })
14175 }
14176 }
14177
14178 /// # Safety
14179 /// The planus compiler generates implementations that initialize
14180 /// the bytes in `write_values`.
14181 unsafe impl ::planus::VectorWrite<CompressionType> for CompressionType {
14182 const STRIDE: usize = 1;
14183
14184 type Value = Self;
14185
14186 #[inline]
14187 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
14188 *self
14189 }
14190
14191 #[inline]
14192 unsafe fn write_values(
14193 values: &[Self],
14194 bytes: *mut ::core::mem::MaybeUninit<u8>,
14195 buffer_position: u32,
14196 ) {
14197 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 1];
14198 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
14199 ::planus::WriteAsPrimitive::write(
14200 v,
14201 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
14202 buffer_position - i as u32,
14203 );
14204 }
14205 }
14206 }
14207
14208 /// Provided for forward compatibility in case we need to support different
14209 /// strategies for compressing the IPC message body (like whole-body
14210 /// compression rather than buffer-level) in the future
14211 ///
14212 /// Generated from these locations:
14213 /// * Enum `BodyCompressionMethod` in the file `Message.fbs:58`
14214 #[derive(
14215 Copy,
14216 Clone,
14217 Debug,
14218 PartialEq,
14219 Eq,
14220 PartialOrd,
14221 Ord,
14222 Hash,
14223 ::serde::Serialize,
14224 ::serde::Deserialize,
14225 )]
14226 #[repr(i8)]
14227 pub enum BodyCompressionMethod {
14228 /// Each constituent buffer is first compressed with the indicated
14229 /// compressor, and then written with the uncompressed length in the first 8
14230 /// bytes as a 64-bit little-endian signed integer followed by the compressed
14231 /// buffer bytes (and then padding as required by the protocol). The
14232 /// uncompressed length may be set to -1 to indicate that the data that
14233 /// follows is not compressed, which can be useful for cases where
14234 /// compression does not yield appreciable savings.
14235 Buffer = 0,
14236 }
14237
14238 impl BodyCompressionMethod {
14239 /// Array containing all valid variants of BodyCompressionMethod
14240 pub const ENUM_VALUES: [Self; 1] = [Self::Buffer];
14241 }
14242
14243 impl ::core::convert::TryFrom<i8> for BodyCompressionMethod {
14244 type Error = ::planus::errors::UnknownEnumTagKind;
14245 #[inline]
14246 fn try_from(
14247 value: i8,
14248 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
14249 {
14250 #[allow(clippy::match_single_binding)]
14251 match value {
14252 0 => ::core::result::Result::Ok(BodyCompressionMethod::Buffer),
14253
14254 _ => ::core::result::Result::Err(
14255 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
14256 ),
14257 }
14258 }
14259 }
14260
14261 impl ::core::convert::From<BodyCompressionMethod> for i8 {
14262 #[inline]
14263 fn from(value: BodyCompressionMethod) -> Self {
14264 value as i8
14265 }
14266 }
14267
14268 /// # Safety
14269 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
14270 unsafe impl ::planus::Primitive for BodyCompressionMethod {
14271 const ALIGNMENT: usize = 1;
14272 const SIZE: usize = 1;
14273 }
14274
14275 impl ::planus::WriteAsPrimitive<BodyCompressionMethod> for BodyCompressionMethod {
14276 #[inline]
14277 fn write<const N: usize>(
14278 &self,
14279 cursor: ::planus::Cursor<'_, N>,
14280 buffer_position: u32,
14281 ) {
14282 (*self as i8).write(cursor, buffer_position);
14283 }
14284 }
14285
14286 impl ::planus::WriteAs<BodyCompressionMethod> for BodyCompressionMethod {
14287 type Prepared = Self;
14288
14289 #[inline]
14290 fn prepare(
14291 &self,
14292 _builder: &mut ::planus::Builder,
14293 ) -> BodyCompressionMethod {
14294 *self
14295 }
14296 }
14297
14298 impl ::planus::WriteAsDefault<BodyCompressionMethod, BodyCompressionMethod>
14299 for BodyCompressionMethod
14300 {
14301 type Prepared = Self;
14302
14303 #[inline]
14304 fn prepare(
14305 &self,
14306 _builder: &mut ::planus::Builder,
14307 default: &BodyCompressionMethod,
14308 ) -> ::core::option::Option<BodyCompressionMethod> {
14309 if self == default {
14310 ::core::option::Option::None
14311 } else {
14312 ::core::option::Option::Some(*self)
14313 }
14314 }
14315 }
14316
14317 impl ::planus::WriteAsOptional<BodyCompressionMethod> for BodyCompressionMethod {
14318 type Prepared = Self;
14319
14320 #[inline]
14321 fn prepare(
14322 &self,
14323 _builder: &mut ::planus::Builder,
14324 ) -> ::core::option::Option<BodyCompressionMethod> {
14325 ::core::option::Option::Some(*self)
14326 }
14327 }
14328
14329 impl<'buf> ::planus::TableRead<'buf> for BodyCompressionMethod {
14330 #[inline]
14331 fn from_buffer(
14332 buffer: ::planus::SliceWithStartOffset<'buf>,
14333 offset: usize,
14334 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
14335 {
14336 let n: i8 = ::planus::TableRead::from_buffer(buffer, offset)?;
14337 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
14338 }
14339 }
14340
14341 impl<'buf> ::planus::VectorReadInner<'buf> for BodyCompressionMethod {
14342 type Error = ::planus::errors::UnknownEnumTag;
14343 const STRIDE: usize = 1;
14344 #[inline]
14345 unsafe fn from_buffer(
14346 buffer: ::planus::SliceWithStartOffset<'buf>,
14347 offset: usize,
14348 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
14349 {
14350 let value = unsafe { *buffer.buffer.get_unchecked(offset) as i8 };
14351 let value: ::core::result::Result<Self, _> =
14352 ::core::convert::TryInto::try_into(value);
14353 value.map_err(|error_kind| {
14354 error_kind.with_error_location(
14355 "BodyCompressionMethod",
14356 "VectorRead::from_buffer",
14357 buffer.offset_from_start,
14358 )
14359 })
14360 }
14361 }
14362
14363 /// # Safety
14364 /// The planus compiler generates implementations that initialize
14365 /// the bytes in `write_values`.
14366 unsafe impl ::planus::VectorWrite<BodyCompressionMethod> for BodyCompressionMethod {
14367 const STRIDE: usize = 1;
14368
14369 type Value = Self;
14370
14371 #[inline]
14372 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
14373 *self
14374 }
14375
14376 #[inline]
14377 unsafe fn write_values(
14378 values: &[Self],
14379 bytes: *mut ::core::mem::MaybeUninit<u8>,
14380 buffer_position: u32,
14381 ) {
14382 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 1];
14383 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
14384 ::planus::WriteAsPrimitive::write(
14385 v,
14386 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
14387 buffer_position - i as u32,
14388 );
14389 }
14390 }
14391 }
14392
14393 /// Optional compression for the memory buffers constituting IPC message
14394 /// bodies. Intended for use with RecordBatch but could be used for other
14395 /// message types
14396 ///
14397 /// Generated from these locations:
14398 /// * Table `BodyCompression` in the file `Message.fbs:72`
14399 #[derive(
14400 Clone,
14401 Debug,
14402 PartialEq,
14403 PartialOrd,
14404 Eq,
14405 Ord,
14406 Hash,
14407 ::serde::Serialize,
14408 ::serde::Deserialize,
14409 )]
14410 pub struct BodyCompression {
14411 /// Compressor library.
14412 /// For LZ4_FRAME, each compressed buffer must consist of a single frame.
14413 pub codec: self::CompressionType,
14414 /// Indicates the way the record batch body was compressed
14415 pub method: self::BodyCompressionMethod,
14416 }
14417
14418 #[allow(clippy::derivable_impls)]
14419 impl ::core::default::Default for BodyCompression {
14420 fn default() -> Self {
14421 Self {
14422 codec: self::CompressionType::Lz4Frame,
14423 method: self::BodyCompressionMethod::Buffer,
14424 }
14425 }
14426 }
14427
14428 impl BodyCompression {
14429 /// Creates a [BodyCompressionBuilder] for serializing an instance of this table.
14430 #[inline]
14431 pub fn builder() -> BodyCompressionBuilder<()> {
14432 BodyCompressionBuilder(())
14433 }
14434
14435 #[allow(clippy::too_many_arguments)]
14436 pub fn create(
14437 builder: &mut ::planus::Builder,
14438 field_codec: impl ::planus::WriteAsDefault<
14439 self::CompressionType,
14440 self::CompressionType,
14441 >,
14442 field_method: impl ::planus::WriteAsDefault<
14443 self::BodyCompressionMethod,
14444 self::BodyCompressionMethod,
14445 >,
14446 ) -> ::planus::Offset<Self> {
14447 let prepared_codec =
14448 field_codec.prepare(builder, &self::CompressionType::Lz4Frame);
14449 let prepared_method =
14450 field_method.prepare(builder, &self::BodyCompressionMethod::Buffer);
14451
14452 let mut table_writer: ::planus::table_writer::TableWriter<8> =
14453 ::core::default::Default::default();
14454 if prepared_codec.is_some() {
14455 table_writer.write_entry::<self::CompressionType>(0);
14456 }
14457 if prepared_method.is_some() {
14458 table_writer.write_entry::<self::BodyCompressionMethod>(1);
14459 }
14460
14461 unsafe {
14462 table_writer.finish(builder, |object_writer| {
14463 if let ::core::option::Option::Some(prepared_codec) =
14464 prepared_codec
14465 {
14466 object_writer.write::<_, _, 1>(&prepared_codec);
14467 }
14468 if let ::core::option::Option::Some(prepared_method) =
14469 prepared_method
14470 {
14471 object_writer.write::<_, _, 1>(&prepared_method);
14472 }
14473 });
14474 }
14475 builder.current_offset()
14476 }
14477 }
14478
14479 impl ::planus::WriteAs<::planus::Offset<BodyCompression>> for BodyCompression {
14480 type Prepared = ::planus::Offset<Self>;
14481
14482 #[inline]
14483 fn prepare(
14484 &self,
14485 builder: &mut ::planus::Builder,
14486 ) -> ::planus::Offset<BodyCompression> {
14487 ::planus::WriteAsOffset::prepare(self, builder)
14488 }
14489 }
14490
14491 impl ::planus::WriteAsOptional<::planus::Offset<BodyCompression>> for BodyCompression {
14492 type Prepared = ::planus::Offset<Self>;
14493
14494 #[inline]
14495 fn prepare(
14496 &self,
14497 builder: &mut ::planus::Builder,
14498 ) -> ::core::option::Option<::planus::Offset<BodyCompression>>
14499 {
14500 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
14501 self, builder,
14502 ))
14503 }
14504 }
14505
14506 impl ::planus::WriteAsOffset<BodyCompression> for BodyCompression {
14507 #[inline]
14508 fn prepare(
14509 &self,
14510 builder: &mut ::planus::Builder,
14511 ) -> ::planus::Offset<BodyCompression> {
14512 BodyCompression::create(builder, self.codec, self.method)
14513 }
14514 }
14515
14516 /// Builder for serializing an instance of the [BodyCompression] type.
14517 ///
14518 /// Can be created using the [BodyCompression::builder] method.
14519 #[derive(Debug)]
14520 #[must_use]
14521 pub struct BodyCompressionBuilder<State>(State);
14522
14523 impl BodyCompressionBuilder<()> {
14524 /// Setter for the [`codec` field](BodyCompression#structfield.codec).
14525 #[inline]
14526 #[allow(clippy::type_complexity)]
14527 pub fn codec<T0>(self, value: T0) -> BodyCompressionBuilder<(T0,)>
14528 where
14529 T0: ::planus::WriteAsDefault<
14530 self::CompressionType,
14531 self::CompressionType,
14532 >,
14533 {
14534 BodyCompressionBuilder((value,))
14535 }
14536
14537 /// Sets the [`codec` field](BodyCompression#structfield.codec) to the default value.
14538 #[inline]
14539 #[allow(clippy::type_complexity)]
14540 pub fn codec_as_default(
14541 self,
14542 ) -> BodyCompressionBuilder<(::planus::DefaultValue,)>
14543 {
14544 self.codec(::planus::DefaultValue)
14545 }
14546 }
14547
14548 impl<T0> BodyCompressionBuilder<(T0,)> {
14549 /// Setter for the [`method` field](BodyCompression#structfield.method).
14550 #[inline]
14551 #[allow(clippy::type_complexity)]
14552 pub fn method<T1>(self, value: T1) -> BodyCompressionBuilder<(T0, T1)>
14553 where
14554 T1: ::planus::WriteAsDefault<
14555 self::BodyCompressionMethod,
14556 self::BodyCompressionMethod,
14557 >,
14558 {
14559 let (v0,) = self.0;
14560 BodyCompressionBuilder((v0, value))
14561 }
14562
14563 /// Sets the [`method` field](BodyCompression#structfield.method) to the default value.
14564 #[inline]
14565 #[allow(clippy::type_complexity)]
14566 pub fn method_as_default(
14567 self,
14568 ) -> BodyCompressionBuilder<(T0, ::planus::DefaultValue)>
14569 {
14570 self.method(::planus::DefaultValue)
14571 }
14572 }
14573
14574 impl<T0, T1> BodyCompressionBuilder<(T0, T1)> {
14575 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BodyCompression].
14576 #[inline]
14577 pub fn finish(
14578 self,
14579 builder: &mut ::planus::Builder,
14580 ) -> ::planus::Offset<BodyCompression>
14581 where
14582 Self: ::planus::WriteAsOffset<BodyCompression>,
14583 {
14584 ::planus::WriteAsOffset::prepare(&self, builder)
14585 }
14586 }
14587
14588 impl<
14589 T0: ::planus::WriteAsDefault<self::CompressionType, self::CompressionType>,
14590 T1: ::planus::WriteAsDefault<
14591 self::BodyCompressionMethod,
14592 self::BodyCompressionMethod,
14593 >,
14594 > ::planus::WriteAs<::planus::Offset<BodyCompression>>
14595 for BodyCompressionBuilder<(T0, T1)>
14596 {
14597 type Prepared = ::planus::Offset<BodyCompression>;
14598
14599 #[inline]
14600 fn prepare(
14601 &self,
14602 builder: &mut ::planus::Builder,
14603 ) -> ::planus::Offset<BodyCompression> {
14604 ::planus::WriteAsOffset::prepare(self, builder)
14605 }
14606 }
14607
14608 impl<
14609 T0: ::planus::WriteAsDefault<self::CompressionType, self::CompressionType>,
14610 T1: ::planus::WriteAsDefault<
14611 self::BodyCompressionMethod,
14612 self::BodyCompressionMethod,
14613 >,
14614 >
14615 ::planus::WriteAsOptional<::planus::Offset<BodyCompression>>
14616 for BodyCompressionBuilder<(T0, T1)>
14617 {
14618 type Prepared = ::planus::Offset<BodyCompression>;
14619
14620 #[inline]
14621 fn prepare(
14622 &self,
14623 builder: &mut ::planus::Builder,
14624 ) -> ::core::option::Option<::planus::Offset<BodyCompression>>
14625 {
14626 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
14627 self, builder,
14628 ))
14629 }
14630 }
14631
14632 impl<
14633 T0: ::planus::WriteAsDefault<self::CompressionType, self::CompressionType>,
14634 T1: ::planus::WriteAsDefault<
14635 self::BodyCompressionMethod,
14636 self::BodyCompressionMethod,
14637 >,
14638 > ::planus::WriteAsOffset<BodyCompression>
14639 for BodyCompressionBuilder<(T0, T1)>
14640 {
14641 #[inline]
14642 fn prepare(
14643 &self,
14644 builder: &mut ::planus::Builder,
14645 ) -> ::planus::Offset<BodyCompression> {
14646 let (v0, v1) = &self.0;
14647 BodyCompression::create(builder, v0, v1)
14648 }
14649 }
14650
14651 /// Reference to a deserialized [BodyCompression].
14652 #[derive(Copy, Clone)]
14653 pub struct BodyCompressionRef<'a>(::planus::table_reader::Table<'a>);
14654
14655 impl<'a> BodyCompressionRef<'a> {
14656 /// Getter for the [`codec` field](BodyCompression#structfield.codec).
14657 #[inline]
14658 pub fn codec(&self) -> ::planus::Result<self::CompressionType> {
14659 ::core::result::Result::Ok(
14660 self.0
14661 .access(0, "BodyCompression", "codec")?
14662 .unwrap_or(self::CompressionType::Lz4Frame),
14663 )
14664 }
14665
14666 /// Getter for the [`method` field](BodyCompression#structfield.method).
14667 #[inline]
14668 pub fn method(&self) -> ::planus::Result<self::BodyCompressionMethod> {
14669 ::core::result::Result::Ok(
14670 self.0
14671 .access(1, "BodyCompression", "method")?
14672 .unwrap_or(self::BodyCompressionMethod::Buffer),
14673 )
14674 }
14675 }
14676
14677 impl<'a> ::core::fmt::Debug for BodyCompressionRef<'a> {
14678 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
14679 let mut f = f.debug_struct("BodyCompressionRef");
14680 f.field("codec", &self.codec());
14681 f.field("method", &self.method());
14682 f.finish()
14683 }
14684 }
14685
14686 impl<'a> ::core::convert::TryFrom<BodyCompressionRef<'a>> for BodyCompression {
14687 type Error = ::planus::Error;
14688
14689 #[allow(unreachable_code)]
14690 fn try_from(value: BodyCompressionRef<'a>) -> ::planus::Result<Self> {
14691 ::core::result::Result::Ok(Self {
14692 codec: ::core::convert::TryInto::try_into(value.codec()?)?,
14693 method: ::core::convert::TryInto::try_into(value.method()?)?,
14694 })
14695 }
14696 }
14697
14698 impl<'a> ::planus::TableRead<'a> for BodyCompressionRef<'a> {
14699 #[inline]
14700 fn from_buffer(
14701 buffer: ::planus::SliceWithStartOffset<'a>,
14702 offset: usize,
14703 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
14704 {
14705 ::core::result::Result::Ok(Self(
14706 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
14707 ))
14708 }
14709 }
14710
14711 impl<'a> ::planus::VectorReadInner<'a> for BodyCompressionRef<'a> {
14712 type Error = ::planus::Error;
14713 const STRIDE: usize = 4;
14714
14715 unsafe fn from_buffer(
14716 buffer: ::planus::SliceWithStartOffset<'a>,
14717 offset: usize,
14718 ) -> ::planus::Result<Self> {
14719 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
14720 error_kind.with_error_location(
14721 "[BodyCompressionRef]",
14722 "get",
14723 buffer.offset_from_start,
14724 )
14725 })
14726 }
14727 }
14728
14729 /// # Safety
14730 /// The planus compiler generates implementations that initialize
14731 /// the bytes in `write_values`.
14732 unsafe impl ::planus::VectorWrite<::planus::Offset<BodyCompression>> for BodyCompression {
14733 type Value = ::planus::Offset<BodyCompression>;
14734 const STRIDE: usize = 4;
14735 #[inline]
14736 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
14737 ::planus::WriteAs::prepare(self, builder)
14738 }
14739
14740 #[inline]
14741 unsafe fn write_values(
14742 values: &[::planus::Offset<BodyCompression>],
14743 bytes: *mut ::core::mem::MaybeUninit<u8>,
14744 buffer_position: u32,
14745 ) {
14746 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
14747 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
14748 ::planus::WriteAsPrimitive::write(
14749 v,
14750 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
14751 buffer_position - (Self::STRIDE * i) as u32,
14752 );
14753 }
14754 }
14755 }
14756
14757 impl<'a> ::planus::ReadAsRoot<'a> for BodyCompressionRef<'a> {
14758 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
14759 ::planus::TableRead::from_buffer(
14760 ::planus::SliceWithStartOffset {
14761 buffer: slice,
14762 offset_from_start: 0,
14763 },
14764 0,
14765 )
14766 .map_err(|error_kind| {
14767 error_kind.with_error_location(
14768 "[BodyCompressionRef]",
14769 "read_as_root",
14770 0,
14771 )
14772 })
14773 }
14774 }
14775
14776 /// A data header describing the shared memory layout of a "record" or "row"
14777 /// batch. Some systems call this a "row batch" internally and others a "record
14778 /// batch".
14779 ///
14780 /// Generated from these locations:
14781 /// * Table `RecordBatch` in the file `Message.fbs:84`
14782 #[derive(
14783 Clone,
14784 Debug,
14785 PartialEq,
14786 PartialOrd,
14787 Eq,
14788 Ord,
14789 Hash,
14790 ::serde::Serialize,
14791 ::serde::Deserialize,
14792 )]
14793 pub struct RecordBatch {
14794 /// number of records / rows. The arrays in the batch should all have this
14795 /// length
14796 pub length: i64,
14797 /// Nodes correspond to the pre-ordered flattened logical schema
14798 pub nodes:
14799 ::core::option::Option<::planus::alloc::vec::Vec<self::FieldNode>>,
14800 /// Buffers correspond to the pre-ordered flattened buffer tree
14801 ///
14802 /// The number of buffers appended to this list depends on the schema. For
14803 /// example, most primitive arrays will have 2 buffers, 1 for the validity
14804 /// bitmap and 1 for the values. For struct arrays, there will only be a
14805 /// single buffer for the validity (nulls) bitmap
14806 pub buffers:
14807 ::core::option::Option<::planus::alloc::vec::Vec<self::Buffer>>,
14808 /// Optional compression of the message body
14809 pub compression: ::core::option::Option<
14810 ::planus::alloc::boxed::Box<self::BodyCompression>,
14811 >,
14812 /// Some types such as Utf8View are represented using a variable number of buffers.
14813 /// For each such Field in the pre-ordered flattened logical schema, there will be
14814 /// an entry in variadicBufferCounts to indicate the number of number of variadic
14815 /// buffers which belong to that Field in the current RecordBatch.
14816 ///
14817 /// For example, the schema
14818 /// col1: Struct<alpha: Int32, beta: BinaryView, gamma: Float64>
14819 /// col2: Utf8View
14820 /// contains two Fields with variadic buffers so variadicBufferCounts will have
14821 /// two entries, the first counting the variadic buffers of `col1.beta` and the
14822 /// second counting `col2`'s.
14823 ///
14824 /// This field may be omitted if and only if the schema contains no Fields with
14825 /// a variable number of buffers, such as BinaryView and Utf8View.
14826 pub variadic_buffer_counts:
14827 ::core::option::Option<::planus::alloc::vec::Vec<i64>>,
14828 }
14829
14830 #[allow(clippy::derivable_impls)]
14831 impl ::core::default::Default for RecordBatch {
14832 fn default() -> Self {
14833 Self {
14834 length: 0,
14835 nodes: ::core::default::Default::default(),
14836 buffers: ::core::default::Default::default(),
14837 compression: ::core::default::Default::default(),
14838 variadic_buffer_counts: ::core::default::Default::default(),
14839 }
14840 }
14841 }
14842
14843 impl RecordBatch {
14844 /// Creates a [RecordBatchBuilder] for serializing an instance of this table.
14845 #[inline]
14846 pub fn builder() -> RecordBatchBuilder<()> {
14847 RecordBatchBuilder(())
14848 }
14849
14850 #[allow(clippy::too_many_arguments)]
14851 pub fn create(
14852 builder: &mut ::planus::Builder,
14853 field_length: impl ::planus::WriteAsDefault<i64, i64>,
14854 field_nodes: impl ::planus::WriteAsOptional<
14855 ::planus::Offset<[self::FieldNode]>,
14856 >,
14857 field_buffers: impl ::planus::WriteAsOptional<
14858 ::planus::Offset<[self::Buffer]>,
14859 >,
14860 field_compression: impl ::planus::WriteAsOptional<
14861 ::planus::Offset<self::BodyCompression>,
14862 >,
14863 field_variadic_buffer_counts: impl ::planus::WriteAsOptional<
14864 ::planus::Offset<[i64]>,
14865 >,
14866 ) -> ::planus::Offset<Self> {
14867 let prepared_length = field_length.prepare(builder, &0);
14868 let prepared_nodes = field_nodes.prepare(builder);
14869 let prepared_buffers = field_buffers.prepare(builder);
14870 let prepared_compression = field_compression.prepare(builder);
14871 let prepared_variadic_buffer_counts =
14872 field_variadic_buffer_counts.prepare(builder);
14873
14874 let mut table_writer: ::planus::table_writer::TableWriter<14> =
14875 ::core::default::Default::default();
14876 if prepared_length.is_some() {
14877 table_writer.write_entry::<i64>(0);
14878 }
14879 if prepared_nodes.is_some() {
14880 table_writer.write_entry::<::planus::Offset<[self::FieldNode]>>(1);
14881 }
14882 if prepared_buffers.is_some() {
14883 table_writer.write_entry::<::planus::Offset<[self::Buffer]>>(2);
14884 }
14885 if prepared_compression.is_some() {
14886 table_writer
14887 .write_entry::<::planus::Offset<self::BodyCompression>>(3);
14888 }
14889 if prepared_variadic_buffer_counts.is_some() {
14890 table_writer.write_entry::<::planus::Offset<[i64]>>(4);
14891 }
14892
14893 unsafe {
14894 table_writer.finish(builder, |object_writer| {
14895 if let ::core::option::Option::Some(prepared_length) =
14896 prepared_length
14897 {
14898 object_writer.write::<_, _, 8>(&prepared_length);
14899 }
14900 if let ::core::option::Option::Some(prepared_nodes) =
14901 prepared_nodes
14902 {
14903 object_writer.write::<_, _, 4>(&prepared_nodes);
14904 }
14905 if let ::core::option::Option::Some(prepared_buffers) =
14906 prepared_buffers
14907 {
14908 object_writer.write::<_, _, 4>(&prepared_buffers);
14909 }
14910 if let ::core::option::Option::Some(prepared_compression) =
14911 prepared_compression
14912 {
14913 object_writer.write::<_, _, 4>(&prepared_compression);
14914 }
14915 if let ::core::option::Option::Some(
14916 prepared_variadic_buffer_counts,
14917 ) = prepared_variadic_buffer_counts
14918 {
14919 object_writer
14920 .write::<_, _, 4>(&prepared_variadic_buffer_counts);
14921 }
14922 });
14923 }
14924 builder.current_offset()
14925 }
14926 }
14927
14928 impl ::planus::WriteAs<::planus::Offset<RecordBatch>> for RecordBatch {
14929 type Prepared = ::planus::Offset<Self>;
14930
14931 #[inline]
14932 fn prepare(
14933 &self,
14934 builder: &mut ::planus::Builder,
14935 ) -> ::planus::Offset<RecordBatch> {
14936 ::planus::WriteAsOffset::prepare(self, builder)
14937 }
14938 }
14939
14940 impl ::planus::WriteAsOptional<::planus::Offset<RecordBatch>> for RecordBatch {
14941 type Prepared = ::planus::Offset<Self>;
14942
14943 #[inline]
14944 fn prepare(
14945 &self,
14946 builder: &mut ::planus::Builder,
14947 ) -> ::core::option::Option<::planus::Offset<RecordBatch>>
14948 {
14949 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
14950 self, builder,
14951 ))
14952 }
14953 }
14954
14955 impl ::planus::WriteAsOffset<RecordBatch> for RecordBatch {
14956 #[inline]
14957 fn prepare(
14958 &self,
14959 builder: &mut ::planus::Builder,
14960 ) -> ::planus::Offset<RecordBatch> {
14961 RecordBatch::create(
14962 builder,
14963 self.length,
14964 &self.nodes,
14965 &self.buffers,
14966 &self.compression,
14967 &self.variadic_buffer_counts,
14968 )
14969 }
14970 }
14971
14972 /// Builder for serializing an instance of the [RecordBatch] type.
14973 ///
14974 /// Can be created using the [RecordBatch::builder] method.
14975 #[derive(Debug)]
14976 #[must_use]
14977 pub struct RecordBatchBuilder<State>(State);
14978
14979 impl RecordBatchBuilder<()> {
14980 /// Setter for the [`length` field](RecordBatch#structfield.length).
14981 #[inline]
14982 #[allow(clippy::type_complexity)]
14983 pub fn length<T0>(self, value: T0) -> RecordBatchBuilder<(T0,)>
14984 where
14985 T0: ::planus::WriteAsDefault<i64, i64>,
14986 {
14987 RecordBatchBuilder((value,))
14988 }
14989
14990 /// Sets the [`length` field](RecordBatch#structfield.length) to the default value.
14991 #[inline]
14992 #[allow(clippy::type_complexity)]
14993 pub fn length_as_default(
14994 self,
14995 ) -> RecordBatchBuilder<(::planus::DefaultValue,)> {
14996 self.length(::planus::DefaultValue)
14997 }
14998 }
14999
15000 impl<T0> RecordBatchBuilder<(T0,)> {
15001 /// Setter for the [`nodes` field](RecordBatch#structfield.nodes).
15002 #[inline]
15003 #[allow(clippy::type_complexity)]
15004 pub fn nodes<T1>(self, value: T1) -> RecordBatchBuilder<(T0, T1)>
15005 where
15006 T1: ::planus::WriteAsOptional<::planus::Offset<[self::FieldNode]>>,
15007 {
15008 let (v0,) = self.0;
15009 RecordBatchBuilder((v0, value))
15010 }
15011
15012 /// Sets the [`nodes` field](RecordBatch#structfield.nodes) to null.
15013 #[inline]
15014 #[allow(clippy::type_complexity)]
15015 pub fn nodes_as_null(self) -> RecordBatchBuilder<(T0, ())> {
15016 self.nodes(())
15017 }
15018 }
15019
15020 impl<T0, T1> RecordBatchBuilder<(T0, T1)> {
15021 /// Setter for the [`buffers` field](RecordBatch#structfield.buffers).
15022 #[inline]
15023 #[allow(clippy::type_complexity)]
15024 pub fn buffers<T2>(self, value: T2) -> RecordBatchBuilder<(T0, T1, T2)>
15025 where
15026 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Buffer]>>,
15027 {
15028 let (v0, v1) = self.0;
15029 RecordBatchBuilder((v0, v1, value))
15030 }
15031
15032 /// Sets the [`buffers` field](RecordBatch#structfield.buffers) to null.
15033 #[inline]
15034 #[allow(clippy::type_complexity)]
15035 pub fn buffers_as_null(self) -> RecordBatchBuilder<(T0, T1, ())> {
15036 self.buffers(())
15037 }
15038 }
15039
15040 impl<T0, T1, T2> RecordBatchBuilder<(T0, T1, T2)> {
15041 /// Setter for the [`compression` field](RecordBatch#structfield.compression).
15042 #[inline]
15043 #[allow(clippy::type_complexity)]
15044 pub fn compression<T3>(
15045 self,
15046 value: T3,
15047 ) -> RecordBatchBuilder<(T0, T1, T2, T3)>
15048 where
15049 T3: ::planus::WriteAsOptional<::planus::Offset<self::BodyCompression>>,
15050 {
15051 let (v0, v1, v2) = self.0;
15052 RecordBatchBuilder((v0, v1, v2, value))
15053 }
15054
15055 /// Sets the [`compression` field](RecordBatch#structfield.compression) to null.
15056 #[inline]
15057 #[allow(clippy::type_complexity)]
15058 pub fn compression_as_null(self) -> RecordBatchBuilder<(T0, T1, T2, ())> {
15059 self.compression(())
15060 }
15061 }
15062
15063 impl<T0, T1, T2, T3> RecordBatchBuilder<(T0, T1, T2, T3)> {
15064 /// Setter for the [`variadicBufferCounts` field](RecordBatch#structfield.variadic_buffer_counts).
15065 #[inline]
15066 #[allow(clippy::type_complexity)]
15067 pub fn variadic_buffer_counts<T4>(
15068 self,
15069 value: T4,
15070 ) -> RecordBatchBuilder<(T0, T1, T2, T3, T4)>
15071 where
15072 T4: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
15073 {
15074 let (v0, v1, v2, v3) = self.0;
15075 RecordBatchBuilder((v0, v1, v2, v3, value))
15076 }
15077
15078 /// Sets the [`variadicBufferCounts` field](RecordBatch#structfield.variadic_buffer_counts) to null.
15079 #[inline]
15080 #[allow(clippy::type_complexity)]
15081 pub fn variadic_buffer_counts_as_null(
15082 self,
15083 ) -> RecordBatchBuilder<(T0, T1, T2, T3, ())> {
15084 self.variadic_buffer_counts(())
15085 }
15086 }
15087
15088 impl<T0, T1, T2, T3, T4> RecordBatchBuilder<(T0, T1, T2, T3, T4)> {
15089 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RecordBatch].
15090 #[inline]
15091 pub fn finish(
15092 self,
15093 builder: &mut ::planus::Builder,
15094 ) -> ::planus::Offset<RecordBatch>
15095 where
15096 Self: ::planus::WriteAsOffset<RecordBatch>,
15097 {
15098 ::planus::WriteAsOffset::prepare(&self, builder)
15099 }
15100 }
15101
15102 impl<
15103 T0: ::planus::WriteAsDefault<i64, i64>,
15104 T1: ::planus::WriteAsOptional<::planus::Offset<[self::FieldNode]>>,
15105 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Buffer]>>,
15106 T3: ::planus::WriteAsOptional<::planus::Offset<self::BodyCompression>>,
15107 T4: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
15108 > ::planus::WriteAs<::planus::Offset<RecordBatch>>
15109 for RecordBatchBuilder<(T0, T1, T2, T3, T4)>
15110 {
15111 type Prepared = ::planus::Offset<RecordBatch>;
15112
15113 #[inline]
15114 fn prepare(
15115 &self,
15116 builder: &mut ::planus::Builder,
15117 ) -> ::planus::Offset<RecordBatch> {
15118 ::planus::WriteAsOffset::prepare(self, builder)
15119 }
15120 }
15121
15122 impl<
15123 T0: ::planus::WriteAsDefault<i64, i64>,
15124 T1: ::planus::WriteAsOptional<::planus::Offset<[self::FieldNode]>>,
15125 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Buffer]>>,
15126 T3: ::planus::WriteAsOptional<::planus::Offset<self::BodyCompression>>,
15127 T4: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
15128 >
15129 ::planus::WriteAsOptional<::planus::Offset<RecordBatch>>
15130 for RecordBatchBuilder<(T0, T1, T2, T3, T4)>
15131 {
15132 type Prepared = ::planus::Offset<RecordBatch>;
15133
15134 #[inline]
15135 fn prepare(
15136 &self,
15137 builder: &mut ::planus::Builder,
15138 ) -> ::core::option::Option<::planus::Offset<RecordBatch>>
15139 {
15140 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
15141 self, builder,
15142 ))
15143 }
15144 }
15145
15146 impl<
15147 T0: ::planus::WriteAsDefault<i64, i64>,
15148 T1: ::planus::WriteAsOptional<::planus::Offset<[self::FieldNode]>>,
15149 T2: ::planus::WriteAsOptional<::planus::Offset<[self::Buffer]>>,
15150 T3: ::planus::WriteAsOptional<::planus::Offset<self::BodyCompression>>,
15151 T4: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
15152 > ::planus::WriteAsOffset<RecordBatch>
15153 for RecordBatchBuilder<(T0, T1, T2, T3, T4)>
15154 {
15155 #[inline]
15156 fn prepare(
15157 &self,
15158 builder: &mut ::planus::Builder,
15159 ) -> ::planus::Offset<RecordBatch> {
15160 let (v0, v1, v2, v3, v4) = &self.0;
15161 RecordBatch::create(builder, v0, v1, v2, v3, v4)
15162 }
15163 }
15164
15165 /// Reference to a deserialized [RecordBatch].
15166 #[derive(Copy, Clone)]
15167 pub struct RecordBatchRef<'a>(::planus::table_reader::Table<'a>);
15168
15169 impl<'a> RecordBatchRef<'a> {
15170 /// Getter for the [`length` field](RecordBatch#structfield.length).
15171 #[inline]
15172 pub fn length(&self) -> ::planus::Result<i64> {
15173 ::core::result::Result::Ok(
15174 self.0.access(0, "RecordBatch", "length")?.unwrap_or(0),
15175 )
15176 }
15177
15178 /// Getter for the [`nodes` field](RecordBatch#structfield.nodes).
15179 #[inline]
15180 pub fn nodes(
15181 &self,
15182 ) -> ::planus::Result<
15183 ::core::option::Option<::planus::Vector<'a, self::FieldNodeRef<'a>>>,
15184 > {
15185 self.0.access(1, "RecordBatch", "nodes")
15186 }
15187
15188 /// Getter for the [`buffers` field](RecordBatch#structfield.buffers).
15189 #[inline]
15190 pub fn buffers(
15191 &self,
15192 ) -> ::planus::Result<
15193 ::core::option::Option<::planus::Vector<'a, self::BufferRef<'a>>>,
15194 > {
15195 self.0.access(2, "RecordBatch", "buffers")
15196 }
15197
15198 /// Getter for the [`compression` field](RecordBatch#structfield.compression).
15199 #[inline]
15200 pub fn compression(
15201 &self,
15202 ) -> ::planus::Result<::core::option::Option<self::BodyCompressionRef<'a>>>
15203 {
15204 self.0.access(3, "RecordBatch", "compression")
15205 }
15206
15207 /// Getter for the [`variadicBufferCounts` field](RecordBatch#structfield.variadic_buffer_counts).
15208 #[inline]
15209 pub fn variadic_buffer_counts(
15210 &self,
15211 ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i64>>>
15212 {
15213 self.0.access(4, "RecordBatch", "variadic_buffer_counts")
15214 }
15215 }
15216
15217 impl<'a> ::core::fmt::Debug for RecordBatchRef<'a> {
15218 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
15219 let mut f = f.debug_struct("RecordBatchRef");
15220 f.field("length", &self.length());
15221 if let ::core::option::Option::Some(field_nodes) =
15222 self.nodes().transpose()
15223 {
15224 f.field("nodes", &field_nodes);
15225 }
15226 if let ::core::option::Option::Some(field_buffers) =
15227 self.buffers().transpose()
15228 {
15229 f.field("buffers", &field_buffers);
15230 }
15231 if let ::core::option::Option::Some(field_compression) =
15232 self.compression().transpose()
15233 {
15234 f.field("compression", &field_compression);
15235 }
15236 if let ::core::option::Option::Some(field_variadic_buffer_counts) =
15237 self.variadic_buffer_counts().transpose()
15238 {
15239 f.field("variadic_buffer_counts", &field_variadic_buffer_counts);
15240 }
15241 f.finish()
15242 }
15243 }
15244
15245 impl<'a> ::core::convert::TryFrom<RecordBatchRef<'a>> for RecordBatch {
15246 type Error = ::planus::Error;
15247
15248 #[allow(unreachable_code)]
15249 fn try_from(value: RecordBatchRef<'a>) -> ::planus::Result<Self> {
15250 ::core::result::Result::Ok(Self {
15251 length: ::core::convert::TryInto::try_into(value.length()?)?,
15252 nodes: if let ::core::option::Option::Some(nodes) = value.nodes()? {
15253 ::core::option::Option::Some(nodes.to_vec()?)
15254 } else {
15255 ::core::option::Option::None
15256 },
15257 buffers: if let ::core::option::Option::Some(buffers) =
15258 value.buffers()?
15259 {
15260 ::core::option::Option::Some(buffers.to_vec()?)
15261 } else {
15262 ::core::option::Option::None
15263 },
15264 compression: if let ::core::option::Option::Some(compression) =
15265 value.compression()?
15266 {
15267 ::core::option::Option::Some(::planus::alloc::boxed::Box::new(
15268 ::core::convert::TryInto::try_into(compression)?,
15269 ))
15270 } else {
15271 ::core::option::Option::None
15272 },
15273 variadic_buffer_counts: if let ::core::option::Option::Some(
15274 variadic_buffer_counts,
15275 ) = value.variadic_buffer_counts()?
15276 {
15277 ::core::option::Option::Some(variadic_buffer_counts.to_vec()?)
15278 } else {
15279 ::core::option::Option::None
15280 },
15281 })
15282 }
15283 }
15284
15285 impl<'a> ::planus::TableRead<'a> for RecordBatchRef<'a> {
15286 #[inline]
15287 fn from_buffer(
15288 buffer: ::planus::SliceWithStartOffset<'a>,
15289 offset: usize,
15290 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
15291 {
15292 ::core::result::Result::Ok(Self(
15293 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
15294 ))
15295 }
15296 }
15297
15298 impl<'a> ::planus::VectorReadInner<'a> for RecordBatchRef<'a> {
15299 type Error = ::planus::Error;
15300 const STRIDE: usize = 4;
15301
15302 unsafe fn from_buffer(
15303 buffer: ::planus::SliceWithStartOffset<'a>,
15304 offset: usize,
15305 ) -> ::planus::Result<Self> {
15306 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
15307 error_kind.with_error_location(
15308 "[RecordBatchRef]",
15309 "get",
15310 buffer.offset_from_start,
15311 )
15312 })
15313 }
15314 }
15315
15316 /// # Safety
15317 /// The planus compiler generates implementations that initialize
15318 /// the bytes in `write_values`.
15319 unsafe impl ::planus::VectorWrite<::planus::Offset<RecordBatch>> for RecordBatch {
15320 type Value = ::planus::Offset<RecordBatch>;
15321 const STRIDE: usize = 4;
15322 #[inline]
15323 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
15324 ::planus::WriteAs::prepare(self, builder)
15325 }
15326
15327 #[inline]
15328 unsafe fn write_values(
15329 values: &[::planus::Offset<RecordBatch>],
15330 bytes: *mut ::core::mem::MaybeUninit<u8>,
15331 buffer_position: u32,
15332 ) {
15333 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
15334 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
15335 ::planus::WriteAsPrimitive::write(
15336 v,
15337 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
15338 buffer_position - (Self::STRIDE * i) as u32,
15339 );
15340 }
15341 }
15342 }
15343
15344 impl<'a> ::planus::ReadAsRoot<'a> for RecordBatchRef<'a> {
15345 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
15346 ::planus::TableRead::from_buffer(
15347 ::planus::SliceWithStartOffset {
15348 buffer: slice,
15349 offset_from_start: 0,
15350 },
15351 0,
15352 )
15353 .map_err(|error_kind| {
15354 error_kind.with_error_location(
15355 "[RecordBatchRef]",
15356 "read_as_root",
15357 0,
15358 )
15359 })
15360 }
15361 }
15362
15363 /// For sending dictionary encoding information. Any Field can be
15364 /// dictionary-encoded, but in this case none of its children may be
15365 /// dictionary-encoded.
15366 /// There is one vector / column per dictionary, but that vector / column
15367 /// may be spread across multiple dictionary batches by using the isDelta
15368 /// flag
15369 ///
15370 /// Generated from these locations:
15371 /// * Table `DictionaryBatch` in the file `Message.fbs:127`
15372 #[derive(
15373 Clone,
15374 Debug,
15375 PartialEq,
15376 PartialOrd,
15377 Eq,
15378 Ord,
15379 Hash,
15380 ::serde::Serialize,
15381 ::serde::Deserialize,
15382 )]
15383 pub struct DictionaryBatch {
15384 /// The field `id` in the table `DictionaryBatch`
15385 pub id: i64,
15386 /// The field `data` in the table `DictionaryBatch`
15387 pub data:
15388 ::core::option::Option<::planus::alloc::boxed::Box<self::RecordBatch>>,
15389 /// If isDelta is true the values in the dictionary are to be appended to a
15390 /// dictionary with the indicated id. If isDelta is false this dictionary
15391 /// should replace the existing dictionary.
15392 pub is_delta: bool,
15393 }
15394
15395 #[allow(clippy::derivable_impls)]
15396 impl ::core::default::Default for DictionaryBatch {
15397 fn default() -> Self {
15398 Self {
15399 id: 0,
15400 data: ::core::default::Default::default(),
15401 is_delta: false,
15402 }
15403 }
15404 }
15405
15406 impl DictionaryBatch {
15407 /// Creates a [DictionaryBatchBuilder] for serializing an instance of this table.
15408 #[inline]
15409 pub fn builder() -> DictionaryBatchBuilder<()> {
15410 DictionaryBatchBuilder(())
15411 }
15412
15413 #[allow(clippy::too_many_arguments)]
15414 pub fn create(
15415 builder: &mut ::planus::Builder,
15416 field_id: impl ::planus::WriteAsDefault<i64, i64>,
15417 field_data: impl ::planus::WriteAsOptional<
15418 ::planus::Offset<self::RecordBatch>,
15419 >,
15420 field_is_delta: impl ::planus::WriteAsDefault<bool, bool>,
15421 ) -> ::planus::Offset<Self> {
15422 let prepared_id = field_id.prepare(builder, &0);
15423 let prepared_data = field_data.prepare(builder);
15424 let prepared_is_delta = field_is_delta.prepare(builder, &false);
15425
15426 let mut table_writer: ::planus::table_writer::TableWriter<10> =
15427 ::core::default::Default::default();
15428 if prepared_id.is_some() {
15429 table_writer.write_entry::<i64>(0);
15430 }
15431 if prepared_data.is_some() {
15432 table_writer.write_entry::<::planus::Offset<self::RecordBatch>>(1);
15433 }
15434 if prepared_is_delta.is_some() {
15435 table_writer.write_entry::<bool>(2);
15436 }
15437
15438 unsafe {
15439 table_writer.finish(builder, |object_writer| {
15440 if let ::core::option::Option::Some(prepared_id) = prepared_id {
15441 object_writer.write::<_, _, 8>(&prepared_id);
15442 }
15443 if let ::core::option::Option::Some(prepared_data) =
15444 prepared_data
15445 {
15446 object_writer.write::<_, _, 4>(&prepared_data);
15447 }
15448 if let ::core::option::Option::Some(prepared_is_delta) =
15449 prepared_is_delta
15450 {
15451 object_writer.write::<_, _, 1>(&prepared_is_delta);
15452 }
15453 });
15454 }
15455 builder.current_offset()
15456 }
15457 }
15458
15459 impl ::planus::WriteAs<::planus::Offset<DictionaryBatch>> for DictionaryBatch {
15460 type Prepared = ::planus::Offset<Self>;
15461
15462 #[inline]
15463 fn prepare(
15464 &self,
15465 builder: &mut ::planus::Builder,
15466 ) -> ::planus::Offset<DictionaryBatch> {
15467 ::planus::WriteAsOffset::prepare(self, builder)
15468 }
15469 }
15470
15471 impl ::planus::WriteAsOptional<::planus::Offset<DictionaryBatch>> for DictionaryBatch {
15472 type Prepared = ::planus::Offset<Self>;
15473
15474 #[inline]
15475 fn prepare(
15476 &self,
15477 builder: &mut ::planus::Builder,
15478 ) -> ::core::option::Option<::planus::Offset<DictionaryBatch>>
15479 {
15480 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
15481 self, builder,
15482 ))
15483 }
15484 }
15485
15486 impl ::planus::WriteAsOffset<DictionaryBatch> for DictionaryBatch {
15487 #[inline]
15488 fn prepare(
15489 &self,
15490 builder: &mut ::planus::Builder,
15491 ) -> ::planus::Offset<DictionaryBatch> {
15492 DictionaryBatch::create(builder, self.id, &self.data, self.is_delta)
15493 }
15494 }
15495
15496 /// Builder for serializing an instance of the [DictionaryBatch] type.
15497 ///
15498 /// Can be created using the [DictionaryBatch::builder] method.
15499 #[derive(Debug)]
15500 #[must_use]
15501 pub struct DictionaryBatchBuilder<State>(State);
15502
15503 impl DictionaryBatchBuilder<()> {
15504 /// Setter for the [`id` field](DictionaryBatch#structfield.id).
15505 #[inline]
15506 #[allow(clippy::type_complexity)]
15507 pub fn id<T0>(self, value: T0) -> DictionaryBatchBuilder<(T0,)>
15508 where
15509 T0: ::planus::WriteAsDefault<i64, i64>,
15510 {
15511 DictionaryBatchBuilder((value,))
15512 }
15513
15514 /// Sets the [`id` field](DictionaryBatch#structfield.id) to the default value.
15515 #[inline]
15516 #[allow(clippy::type_complexity)]
15517 pub fn id_as_default(
15518 self,
15519 ) -> DictionaryBatchBuilder<(::planus::DefaultValue,)>
15520 {
15521 self.id(::planus::DefaultValue)
15522 }
15523 }
15524
15525 impl<T0> DictionaryBatchBuilder<(T0,)> {
15526 /// Setter for the [`data` field](DictionaryBatch#structfield.data).
15527 #[inline]
15528 #[allow(clippy::type_complexity)]
15529 pub fn data<T1>(self, value: T1) -> DictionaryBatchBuilder<(T0, T1)>
15530 where
15531 T1: ::planus::WriteAsOptional<::planus::Offset<self::RecordBatch>>,
15532 {
15533 let (v0,) = self.0;
15534 DictionaryBatchBuilder((v0, value))
15535 }
15536
15537 /// Sets the [`data` field](DictionaryBatch#structfield.data) to null.
15538 #[inline]
15539 #[allow(clippy::type_complexity)]
15540 pub fn data_as_null(self) -> DictionaryBatchBuilder<(T0, ())> {
15541 self.data(())
15542 }
15543 }
15544
15545 impl<T0, T1> DictionaryBatchBuilder<(T0, T1)> {
15546 /// Setter for the [`isDelta` field](DictionaryBatch#structfield.is_delta).
15547 #[inline]
15548 #[allow(clippy::type_complexity)]
15549 pub fn is_delta<T2>(self, value: T2) -> DictionaryBatchBuilder<(T0, T1, T2)>
15550 where
15551 T2: ::planus::WriteAsDefault<bool, bool>,
15552 {
15553 let (v0, v1) = self.0;
15554 DictionaryBatchBuilder((v0, v1, value))
15555 }
15556
15557 /// Sets the [`isDelta` field](DictionaryBatch#structfield.is_delta) to the default value.
15558 #[inline]
15559 #[allow(clippy::type_complexity)]
15560 pub fn is_delta_as_default(
15561 self,
15562 ) -> DictionaryBatchBuilder<(T0, T1, ::planus::DefaultValue)>
15563 {
15564 self.is_delta(::planus::DefaultValue)
15565 }
15566 }
15567
15568 impl<T0, T1, T2> DictionaryBatchBuilder<(T0, T1, T2)> {
15569 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DictionaryBatch].
15570 #[inline]
15571 pub fn finish(
15572 self,
15573 builder: &mut ::planus::Builder,
15574 ) -> ::planus::Offset<DictionaryBatch>
15575 where
15576 Self: ::planus::WriteAsOffset<DictionaryBatch>,
15577 {
15578 ::planus::WriteAsOffset::prepare(&self, builder)
15579 }
15580 }
15581
15582 impl<
15583 T0: ::planus::WriteAsDefault<i64, i64>,
15584 T1: ::planus::WriteAsOptional<::planus::Offset<self::RecordBatch>>,
15585 T2: ::planus::WriteAsDefault<bool, bool>,
15586 > ::planus::WriteAs<::planus::Offset<DictionaryBatch>>
15587 for DictionaryBatchBuilder<(T0, T1, T2)>
15588 {
15589 type Prepared = ::planus::Offset<DictionaryBatch>;
15590
15591 #[inline]
15592 fn prepare(
15593 &self,
15594 builder: &mut ::planus::Builder,
15595 ) -> ::planus::Offset<DictionaryBatch> {
15596 ::planus::WriteAsOffset::prepare(self, builder)
15597 }
15598 }
15599
15600 impl<
15601 T0: ::planus::WriteAsDefault<i64, i64>,
15602 T1: ::planus::WriteAsOptional<::planus::Offset<self::RecordBatch>>,
15603 T2: ::planus::WriteAsDefault<bool, bool>,
15604 >
15605 ::planus::WriteAsOptional<::planus::Offset<DictionaryBatch>>
15606 for DictionaryBatchBuilder<(T0, T1, T2)>
15607 {
15608 type Prepared = ::planus::Offset<DictionaryBatch>;
15609
15610 #[inline]
15611 fn prepare(
15612 &self,
15613 builder: &mut ::planus::Builder,
15614 ) -> ::core::option::Option<::planus::Offset<DictionaryBatch>>
15615 {
15616 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
15617 self, builder,
15618 ))
15619 }
15620 }
15621
15622 impl<
15623 T0: ::planus::WriteAsDefault<i64, i64>,
15624 T1: ::planus::WriteAsOptional<::planus::Offset<self::RecordBatch>>,
15625 T2: ::planus::WriteAsDefault<bool, bool>,
15626 > ::planus::WriteAsOffset<DictionaryBatch>
15627 for DictionaryBatchBuilder<(T0, T1, T2)>
15628 {
15629 #[inline]
15630 fn prepare(
15631 &self,
15632 builder: &mut ::planus::Builder,
15633 ) -> ::planus::Offset<DictionaryBatch> {
15634 let (v0, v1, v2) = &self.0;
15635 DictionaryBatch::create(builder, v0, v1, v2)
15636 }
15637 }
15638
15639 /// Reference to a deserialized [DictionaryBatch].
15640 #[derive(Copy, Clone)]
15641 pub struct DictionaryBatchRef<'a>(::planus::table_reader::Table<'a>);
15642
15643 impl<'a> DictionaryBatchRef<'a> {
15644 /// Getter for the [`id` field](DictionaryBatch#structfield.id).
15645 #[inline]
15646 pub fn id(&self) -> ::planus::Result<i64> {
15647 ::core::result::Result::Ok(
15648 self.0.access(0, "DictionaryBatch", "id")?.unwrap_or(0),
15649 )
15650 }
15651
15652 /// Getter for the [`data` field](DictionaryBatch#structfield.data).
15653 #[inline]
15654 pub fn data(
15655 &self,
15656 ) -> ::planus::Result<::core::option::Option<self::RecordBatchRef<'a>>>
15657 {
15658 self.0.access(1, "DictionaryBatch", "data")
15659 }
15660
15661 /// Getter for the [`isDelta` field](DictionaryBatch#structfield.is_delta).
15662 #[inline]
15663 pub fn is_delta(&self) -> ::planus::Result<bool> {
15664 ::core::result::Result::Ok(
15665 self.0
15666 .access(2, "DictionaryBatch", "is_delta")?
15667 .unwrap_or(false),
15668 )
15669 }
15670 }
15671
15672 impl<'a> ::core::fmt::Debug for DictionaryBatchRef<'a> {
15673 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
15674 let mut f = f.debug_struct("DictionaryBatchRef");
15675 f.field("id", &self.id());
15676 if let ::core::option::Option::Some(field_data) =
15677 self.data().transpose()
15678 {
15679 f.field("data", &field_data);
15680 }
15681 f.field("is_delta", &self.is_delta());
15682 f.finish()
15683 }
15684 }
15685
15686 impl<'a> ::core::convert::TryFrom<DictionaryBatchRef<'a>> for DictionaryBatch {
15687 type Error = ::planus::Error;
15688
15689 #[allow(unreachable_code)]
15690 fn try_from(value: DictionaryBatchRef<'a>) -> ::planus::Result<Self> {
15691 ::core::result::Result::Ok(Self {
15692 id: ::core::convert::TryInto::try_into(value.id()?)?,
15693 data: if let ::core::option::Option::Some(data) = value.data()? {
15694 ::core::option::Option::Some(::planus::alloc::boxed::Box::new(
15695 ::core::convert::TryInto::try_into(data)?,
15696 ))
15697 } else {
15698 ::core::option::Option::None
15699 },
15700 is_delta: ::core::convert::TryInto::try_into(value.is_delta()?)?,
15701 })
15702 }
15703 }
15704
15705 impl<'a> ::planus::TableRead<'a> for DictionaryBatchRef<'a> {
15706 #[inline]
15707 fn from_buffer(
15708 buffer: ::planus::SliceWithStartOffset<'a>,
15709 offset: usize,
15710 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
15711 {
15712 ::core::result::Result::Ok(Self(
15713 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
15714 ))
15715 }
15716 }
15717
15718 impl<'a> ::planus::VectorReadInner<'a> for DictionaryBatchRef<'a> {
15719 type Error = ::planus::Error;
15720 const STRIDE: usize = 4;
15721
15722 unsafe fn from_buffer(
15723 buffer: ::planus::SliceWithStartOffset<'a>,
15724 offset: usize,
15725 ) -> ::planus::Result<Self> {
15726 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
15727 error_kind.with_error_location(
15728 "[DictionaryBatchRef]",
15729 "get",
15730 buffer.offset_from_start,
15731 )
15732 })
15733 }
15734 }
15735
15736 /// # Safety
15737 /// The planus compiler generates implementations that initialize
15738 /// the bytes in `write_values`.
15739 unsafe impl ::planus::VectorWrite<::planus::Offset<DictionaryBatch>> for DictionaryBatch {
15740 type Value = ::planus::Offset<DictionaryBatch>;
15741 const STRIDE: usize = 4;
15742 #[inline]
15743 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
15744 ::planus::WriteAs::prepare(self, builder)
15745 }
15746
15747 #[inline]
15748 unsafe fn write_values(
15749 values: &[::planus::Offset<DictionaryBatch>],
15750 bytes: *mut ::core::mem::MaybeUninit<u8>,
15751 buffer_position: u32,
15752 ) {
15753 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
15754 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
15755 ::planus::WriteAsPrimitive::write(
15756 v,
15757 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
15758 buffer_position - (Self::STRIDE * i) as u32,
15759 );
15760 }
15761 }
15762 }
15763
15764 impl<'a> ::planus::ReadAsRoot<'a> for DictionaryBatchRef<'a> {
15765 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
15766 ::planus::TableRead::from_buffer(
15767 ::planus::SliceWithStartOffset {
15768 buffer: slice,
15769 offset_from_start: 0,
15770 },
15771 0,
15772 )
15773 .map_err(|error_kind| {
15774 error_kind.with_error_location(
15775 "[DictionaryBatchRef]",
15776 "read_as_root",
15777 0,
15778 )
15779 })
15780 }
15781 }
15782
15783 /// ----------------------------------------------------------------------
15784 /// The root Message type
15785 /// This union enables us to easily send different message types without
15786 /// redundant storage, and in the future we can easily add new message types.
15787 ///
15788 /// Arrow implementations do not need to implement all of the message types,
15789 /// which may include experimental metadata types. For maximum compatibility,
15790 /// it is best to send data using RecordBatch
15791 ///
15792 /// Generated from these locations:
15793 /// * Union `MessageHeader` in the file `Message.fbs:146`
15794 #[derive(
15795 Clone,
15796 Debug,
15797 PartialEq,
15798 PartialOrd,
15799 Eq,
15800 Ord,
15801 Hash,
15802 ::serde::Serialize,
15803 ::serde::Deserialize,
15804 )]
15805 pub enum MessageHeader {
15806 /// The variant of type `Schema` in the union `MessageHeader`
15807 Schema(::planus::alloc::boxed::Box<self::Schema>),
15808
15809 /// The variant of type `DictionaryBatch` in the union `MessageHeader`
15810 DictionaryBatch(::planus::alloc::boxed::Box<self::DictionaryBatch>),
15811
15812 /// The variant of type `RecordBatch` in the union `MessageHeader`
15813 RecordBatch(::planus::alloc::boxed::Box<self::RecordBatch>),
15814
15815 /// The variant of type `Tensor` in the union `MessageHeader`
15816 Tensor(::planus::alloc::boxed::Box<self::Tensor>),
15817
15818 /// The variant of type `SparseTensor` in the union `MessageHeader`
15819 SparseTensor(::planus::alloc::boxed::Box<self::SparseTensor>),
15820 }
15821
15822 impl MessageHeader {
15823 /// Creates a [MessageHeaderBuilder] for serializing an instance of this table.
15824 #[inline]
15825 pub fn builder() -> MessageHeaderBuilder<::planus::Uninitialized> {
15826 MessageHeaderBuilder(::planus::Uninitialized)
15827 }
15828
15829 #[inline]
15830 pub fn create_schema(
15831 builder: &mut ::planus::Builder,
15832 value: impl ::planus::WriteAsOffset<self::Schema>,
15833 ) -> ::planus::UnionOffset<Self> {
15834 ::planus::UnionOffset::new(1, value.prepare(builder).downcast())
15835 }
15836
15837 #[inline]
15838 pub fn create_dictionary_batch(
15839 builder: &mut ::planus::Builder,
15840 value: impl ::planus::WriteAsOffset<self::DictionaryBatch>,
15841 ) -> ::planus::UnionOffset<Self> {
15842 ::planus::UnionOffset::new(2, value.prepare(builder).downcast())
15843 }
15844
15845 #[inline]
15846 pub fn create_record_batch(
15847 builder: &mut ::planus::Builder,
15848 value: impl ::planus::WriteAsOffset<self::RecordBatch>,
15849 ) -> ::planus::UnionOffset<Self> {
15850 ::planus::UnionOffset::new(3, value.prepare(builder).downcast())
15851 }
15852
15853 #[inline]
15854 pub fn create_tensor(
15855 builder: &mut ::planus::Builder,
15856 value: impl ::planus::WriteAsOffset<self::Tensor>,
15857 ) -> ::planus::UnionOffset<Self> {
15858 ::planus::UnionOffset::new(4, value.prepare(builder).downcast())
15859 }
15860
15861 #[inline]
15862 pub fn create_sparse_tensor(
15863 builder: &mut ::planus::Builder,
15864 value: impl ::planus::WriteAsOffset<self::SparseTensor>,
15865 ) -> ::planus::UnionOffset<Self> {
15866 ::planus::UnionOffset::new(5, value.prepare(builder).downcast())
15867 }
15868 }
15869
15870 impl ::planus::WriteAsUnion<MessageHeader> for MessageHeader {
15871 #[inline]
15872 fn prepare(
15873 &self,
15874 builder: &mut ::planus::Builder,
15875 ) -> ::planus::UnionOffset<Self> {
15876 match self {
15877 Self::Schema(value) => Self::create_schema(builder, value),
15878 Self::DictionaryBatch(value) => {
15879 Self::create_dictionary_batch(builder, value)
15880 }
15881 Self::RecordBatch(value) => {
15882 Self::create_record_batch(builder, value)
15883 }
15884 Self::Tensor(value) => Self::create_tensor(builder, value),
15885 Self::SparseTensor(value) => {
15886 Self::create_sparse_tensor(builder, value)
15887 }
15888 }
15889 }
15890 }
15891
15892 impl ::planus::WriteAsOptionalUnion<MessageHeader> for MessageHeader {
15893 #[inline]
15894 fn prepare(
15895 &self,
15896 builder: &mut ::planus::Builder,
15897 ) -> ::core::option::Option<::planus::UnionOffset<Self>>
15898 {
15899 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
15900 self, builder,
15901 ))
15902 }
15903 }
15904
15905 /// Builder for serializing an instance of the [MessageHeader] type.
15906 ///
15907 /// Can be created using the [MessageHeader::builder] method.
15908 #[derive(Debug)]
15909 #[must_use]
15910 pub struct MessageHeaderBuilder<T>(T);
15911
15912 impl MessageHeaderBuilder<::planus::Uninitialized> {
15913 /// Creates an instance of the [`Schema` variant](MessageHeader#variant.Schema).
15914 #[inline]
15915 pub fn schema<T>(
15916 self,
15917 value: T,
15918 ) -> MessageHeaderBuilder<::planus::Initialized<1, T>>
15919 where
15920 T: ::planus::WriteAsOffset<self::Schema>,
15921 {
15922 MessageHeaderBuilder(::planus::Initialized(value))
15923 }
15924
15925 /// Creates an instance of the [`DictionaryBatch` variant](MessageHeader#variant.DictionaryBatch).
15926 #[inline]
15927 pub fn dictionary_batch<T>(
15928 self,
15929 value: T,
15930 ) -> MessageHeaderBuilder<::planus::Initialized<2, T>>
15931 where
15932 T: ::planus::WriteAsOffset<self::DictionaryBatch>,
15933 {
15934 MessageHeaderBuilder(::planus::Initialized(value))
15935 }
15936
15937 /// Creates an instance of the [`RecordBatch` variant](MessageHeader#variant.RecordBatch).
15938 #[inline]
15939 pub fn record_batch<T>(
15940 self,
15941 value: T,
15942 ) -> MessageHeaderBuilder<::planus::Initialized<3, T>>
15943 where
15944 T: ::planus::WriteAsOffset<self::RecordBatch>,
15945 {
15946 MessageHeaderBuilder(::planus::Initialized(value))
15947 }
15948
15949 /// Creates an instance of the [`Tensor` variant](MessageHeader#variant.Tensor).
15950 #[inline]
15951 pub fn tensor<T>(
15952 self,
15953 value: T,
15954 ) -> MessageHeaderBuilder<::planus::Initialized<4, T>>
15955 where
15956 T: ::planus::WriteAsOffset<self::Tensor>,
15957 {
15958 MessageHeaderBuilder(::planus::Initialized(value))
15959 }
15960
15961 /// Creates an instance of the [`SparseTensor` variant](MessageHeader#variant.SparseTensor).
15962 #[inline]
15963 pub fn sparse_tensor<T>(
15964 self,
15965 value: T,
15966 ) -> MessageHeaderBuilder<::planus::Initialized<5, T>>
15967 where
15968 T: ::planus::WriteAsOffset<self::SparseTensor>,
15969 {
15970 MessageHeaderBuilder(::planus::Initialized(value))
15971 }
15972 }
15973
15974 impl<const N: u8, T> MessageHeaderBuilder<::planus::Initialized<N, T>> {
15975 /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [MessageHeader].
15976 #[inline]
15977 pub fn finish(
15978 self,
15979 builder: &mut ::planus::Builder,
15980 ) -> ::planus::UnionOffset<MessageHeader>
15981 where
15982 Self: ::planus::WriteAsUnion<MessageHeader>,
15983 {
15984 ::planus::WriteAsUnion::prepare(&self, builder)
15985 }
15986 }
15987
15988 impl<T> ::planus::WriteAsUnion<MessageHeader> for MessageHeaderBuilder<::planus::Initialized<1, T>>
15989 where
15990 T: ::planus::WriteAsOffset<self::Schema>,
15991 {
15992 #[inline]
15993 fn prepare(
15994 &self,
15995 builder: &mut ::planus::Builder,
15996 ) -> ::planus::UnionOffset<MessageHeader> {
15997 ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast())
15998 }
15999 }
16000
16001 impl<T> ::planus::WriteAsOptionalUnion<MessageHeader>
16002 for MessageHeaderBuilder<::planus::Initialized<1, T>>
16003 where
16004 T: ::planus::WriteAsOffset<self::Schema>,
16005 {
16006 #[inline]
16007 fn prepare(
16008 &self,
16009 builder: &mut ::planus::Builder,
16010 ) -> ::core::option::Option<::planus::UnionOffset<MessageHeader>>
16011 {
16012 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
16013 self, builder,
16014 ))
16015 }
16016 }
16017 impl<T> ::planus::WriteAsUnion<MessageHeader> for MessageHeaderBuilder<::planus::Initialized<2, T>>
16018 where
16019 T: ::planus::WriteAsOffset<self::DictionaryBatch>,
16020 {
16021 #[inline]
16022 fn prepare(
16023 &self,
16024 builder: &mut ::planus::Builder,
16025 ) -> ::planus::UnionOffset<MessageHeader> {
16026 ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast())
16027 }
16028 }
16029
16030 impl<T> ::planus::WriteAsOptionalUnion<MessageHeader>
16031 for MessageHeaderBuilder<::planus::Initialized<2, T>>
16032 where
16033 T: ::planus::WriteAsOffset<self::DictionaryBatch>,
16034 {
16035 #[inline]
16036 fn prepare(
16037 &self,
16038 builder: &mut ::planus::Builder,
16039 ) -> ::core::option::Option<::planus::UnionOffset<MessageHeader>>
16040 {
16041 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
16042 self, builder,
16043 ))
16044 }
16045 }
16046 impl<T> ::planus::WriteAsUnion<MessageHeader> for MessageHeaderBuilder<::planus::Initialized<3, T>>
16047 where
16048 T: ::planus::WriteAsOffset<self::RecordBatch>,
16049 {
16050 #[inline]
16051 fn prepare(
16052 &self,
16053 builder: &mut ::planus::Builder,
16054 ) -> ::planus::UnionOffset<MessageHeader> {
16055 ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast())
16056 }
16057 }
16058
16059 impl<T> ::planus::WriteAsOptionalUnion<MessageHeader>
16060 for MessageHeaderBuilder<::planus::Initialized<3, T>>
16061 where
16062 T: ::planus::WriteAsOffset<self::RecordBatch>,
16063 {
16064 #[inline]
16065 fn prepare(
16066 &self,
16067 builder: &mut ::planus::Builder,
16068 ) -> ::core::option::Option<::planus::UnionOffset<MessageHeader>>
16069 {
16070 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
16071 self, builder,
16072 ))
16073 }
16074 }
16075 impl<T> ::planus::WriteAsUnion<MessageHeader> for MessageHeaderBuilder<::planus::Initialized<4, T>>
16076 where
16077 T: ::planus::WriteAsOffset<self::Tensor>,
16078 {
16079 #[inline]
16080 fn prepare(
16081 &self,
16082 builder: &mut ::planus::Builder,
16083 ) -> ::planus::UnionOffset<MessageHeader> {
16084 ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast())
16085 }
16086 }
16087
16088 impl<T> ::planus::WriteAsOptionalUnion<MessageHeader>
16089 for MessageHeaderBuilder<::planus::Initialized<4, T>>
16090 where
16091 T: ::planus::WriteAsOffset<self::Tensor>,
16092 {
16093 #[inline]
16094 fn prepare(
16095 &self,
16096 builder: &mut ::planus::Builder,
16097 ) -> ::core::option::Option<::planus::UnionOffset<MessageHeader>>
16098 {
16099 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
16100 self, builder,
16101 ))
16102 }
16103 }
16104 impl<T> ::planus::WriteAsUnion<MessageHeader> for MessageHeaderBuilder<::planus::Initialized<5, T>>
16105 where
16106 T: ::planus::WriteAsOffset<self::SparseTensor>,
16107 {
16108 #[inline]
16109 fn prepare(
16110 &self,
16111 builder: &mut ::planus::Builder,
16112 ) -> ::planus::UnionOffset<MessageHeader> {
16113 ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast())
16114 }
16115 }
16116
16117 impl<T> ::planus::WriteAsOptionalUnion<MessageHeader>
16118 for MessageHeaderBuilder<::planus::Initialized<5, T>>
16119 where
16120 T: ::planus::WriteAsOffset<self::SparseTensor>,
16121 {
16122 #[inline]
16123 fn prepare(
16124 &self,
16125 builder: &mut ::planus::Builder,
16126 ) -> ::core::option::Option<::planus::UnionOffset<MessageHeader>>
16127 {
16128 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
16129 self, builder,
16130 ))
16131 }
16132 }
16133
16134 /// Reference to a deserialized [MessageHeader].
16135 #[derive(Copy, Clone, Debug)]
16136 pub enum MessageHeaderRef<'a> {
16137 Schema(self::SchemaRef<'a>),
16138 DictionaryBatch(self::DictionaryBatchRef<'a>),
16139 RecordBatch(self::RecordBatchRef<'a>),
16140 Tensor(self::TensorRef<'a>),
16141 SparseTensor(self::SparseTensorRef<'a>),
16142 }
16143
16144 impl<'a> ::core::convert::TryFrom<MessageHeaderRef<'a>> for MessageHeader {
16145 type Error = ::planus::Error;
16146
16147 fn try_from(value: MessageHeaderRef<'a>) -> ::planus::Result<Self> {
16148 ::core::result::Result::Ok(match value {
16149 MessageHeaderRef::Schema(value) => {
16150 Self::Schema(::planus::alloc::boxed::Box::new(
16151 ::core::convert::TryFrom::try_from(value)?,
16152 ))
16153 }
16154
16155 MessageHeaderRef::DictionaryBatch(value) => {
16156 Self::DictionaryBatch(::planus::alloc::boxed::Box::new(
16157 ::core::convert::TryFrom::try_from(value)?,
16158 ))
16159 }
16160
16161 MessageHeaderRef::RecordBatch(value) => {
16162 Self::RecordBatch(::planus::alloc::boxed::Box::new(
16163 ::core::convert::TryFrom::try_from(value)?,
16164 ))
16165 }
16166
16167 MessageHeaderRef::Tensor(value) => {
16168 Self::Tensor(::planus::alloc::boxed::Box::new(
16169 ::core::convert::TryFrom::try_from(value)?,
16170 ))
16171 }
16172
16173 MessageHeaderRef::SparseTensor(value) => {
16174 Self::SparseTensor(::planus::alloc::boxed::Box::new(
16175 ::core::convert::TryFrom::try_from(value)?,
16176 ))
16177 }
16178 })
16179 }
16180 }
16181
16182 impl<'a> ::planus::TableReadUnion<'a> for MessageHeaderRef<'a> {
16183 fn from_buffer(
16184 buffer: ::planus::SliceWithStartOffset<'a>,
16185 tag: u8,
16186 field_offset: usize,
16187 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
16188 {
16189 match tag {
16190 1 => ::core::result::Result::Ok(Self::Schema(
16191 ::planus::TableRead::from_buffer(buffer, field_offset)?,
16192 )),
16193 2 => ::core::result::Result::Ok(Self::DictionaryBatch(
16194 ::planus::TableRead::from_buffer(buffer, field_offset)?,
16195 )),
16196 3 => ::core::result::Result::Ok(Self::RecordBatch(
16197 ::planus::TableRead::from_buffer(buffer, field_offset)?,
16198 )),
16199 4 => ::core::result::Result::Ok(Self::Tensor(
16200 ::planus::TableRead::from_buffer(buffer, field_offset)?,
16201 )),
16202 5 => ::core::result::Result::Ok(Self::SparseTensor(
16203 ::planus::TableRead::from_buffer(buffer, field_offset)?,
16204 )),
16205 _ => ::core::result::Result::Err(
16206 ::planus::errors::ErrorKind::UnknownUnionTag { tag },
16207 ),
16208 }
16209 }
16210 }
16211
16212 impl<'a> ::planus::VectorReadUnion<'a> for MessageHeaderRef<'a> {
16213 const VECTOR_NAME: &'static str = "[MessageHeaderRef]";
16214 }
16215
16216 /// The table `Message` in the namespace `org.apache.arrow.flatbuf`
16217 ///
16218 /// Generated from these locations:
16219 /// * Table `Message` in the file `Message.fbs:150`
16220 #[derive(
16221 Clone,
16222 Debug,
16223 PartialEq,
16224 PartialOrd,
16225 Eq,
16226 Ord,
16227 Hash,
16228 ::serde::Serialize,
16229 ::serde::Deserialize,
16230 )]
16231 pub struct Message {
16232 /// The field `version` in the table `Message`
16233 pub version: self::MetadataVersion,
16234 /// The field `header` in the table `Message`
16235 pub header: ::core::option::Option<self::MessageHeader>,
16236 /// The field `bodyLength` in the table `Message`
16237 pub body_length: i64,
16238 /// The field `custom_metadata` in the table `Message`
16239 pub custom_metadata:
16240 ::core::option::Option<::planus::alloc::vec::Vec<self::KeyValue>>,
16241 }
16242
16243 #[allow(clippy::derivable_impls)]
16244 impl ::core::default::Default for Message {
16245 fn default() -> Self {
16246 Self {
16247 version: self::MetadataVersion::V1,
16248 header: ::core::default::Default::default(),
16249 body_length: 0,
16250 custom_metadata: ::core::default::Default::default(),
16251 }
16252 }
16253 }
16254
16255 impl Message {
16256 /// Creates a [MessageBuilder] for serializing an instance of this table.
16257 #[inline]
16258 pub fn builder() -> MessageBuilder<()> {
16259 MessageBuilder(())
16260 }
16261
16262 #[allow(clippy::too_many_arguments)]
16263 pub fn create(
16264 builder: &mut ::planus::Builder,
16265 field_version: impl ::planus::WriteAsDefault<
16266 self::MetadataVersion,
16267 self::MetadataVersion,
16268 >,
16269 field_header: impl ::planus::WriteAsOptionalUnion<self::MessageHeader>,
16270 field_body_length: impl ::planus::WriteAsDefault<i64, i64>,
16271 field_custom_metadata: impl ::planus::WriteAsOptional<
16272 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
16273 >,
16274 ) -> ::planus::Offset<Self> {
16275 let prepared_version =
16276 field_version.prepare(builder, &self::MetadataVersion::V1);
16277 let prepared_header = field_header.prepare(builder);
16278 let prepared_body_length = field_body_length.prepare(builder, &0);
16279 let prepared_custom_metadata = field_custom_metadata.prepare(builder);
16280
16281 let mut table_writer: ::planus::table_writer::TableWriter<14> =
16282 ::core::default::Default::default();
16283 if prepared_body_length.is_some() {
16284 table_writer.write_entry::<i64>(3);
16285 }
16286 if prepared_header.is_some() {
16287 table_writer
16288 .write_entry::<::planus::Offset<self::MessageHeader>>(2);
16289 }
16290 if prepared_custom_metadata.is_some() {
16291 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::KeyValue>]>>(4);
16292 }
16293 if prepared_version.is_some() {
16294 table_writer.write_entry::<self::MetadataVersion>(0);
16295 }
16296 if prepared_header.is_some() {
16297 table_writer.write_entry::<u8>(1);
16298 }
16299
16300 unsafe {
16301 table_writer.finish(builder, |object_writer| {
16302 if let ::core::option::Option::Some(prepared_body_length) =
16303 prepared_body_length
16304 {
16305 object_writer.write::<_, _, 8>(&prepared_body_length);
16306 }
16307 if let ::core::option::Option::Some(prepared_header) =
16308 prepared_header
16309 {
16310 object_writer.write::<_, _, 4>(&prepared_header.offset());
16311 }
16312 if let ::core::option::Option::Some(prepared_custom_metadata) =
16313 prepared_custom_metadata
16314 {
16315 object_writer.write::<_, _, 4>(&prepared_custom_metadata);
16316 }
16317 if let ::core::option::Option::Some(prepared_version) =
16318 prepared_version
16319 {
16320 object_writer.write::<_, _, 2>(&prepared_version);
16321 }
16322 if let ::core::option::Option::Some(prepared_header) =
16323 prepared_header
16324 {
16325 object_writer.write::<_, _, 1>(&prepared_header.tag());
16326 }
16327 });
16328 }
16329 builder.current_offset()
16330 }
16331 }
16332
16333 impl ::planus::WriteAs<::planus::Offset<Message>> for Message {
16334 type Prepared = ::planus::Offset<Self>;
16335
16336 #[inline]
16337 fn prepare(
16338 &self,
16339 builder: &mut ::planus::Builder,
16340 ) -> ::planus::Offset<Message> {
16341 ::planus::WriteAsOffset::prepare(self, builder)
16342 }
16343 }
16344
16345 impl ::planus::WriteAsOptional<::planus::Offset<Message>> for Message {
16346 type Prepared = ::planus::Offset<Self>;
16347
16348 #[inline]
16349 fn prepare(
16350 &self,
16351 builder: &mut ::planus::Builder,
16352 ) -> ::core::option::Option<::planus::Offset<Message>>
16353 {
16354 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
16355 self, builder,
16356 ))
16357 }
16358 }
16359
16360 impl ::planus::WriteAsOffset<Message> for Message {
16361 #[inline]
16362 fn prepare(
16363 &self,
16364 builder: &mut ::planus::Builder,
16365 ) -> ::planus::Offset<Message> {
16366 Message::create(
16367 builder,
16368 self.version,
16369 &self.header,
16370 self.body_length,
16371 &self.custom_metadata,
16372 )
16373 }
16374 }
16375
16376 /// Builder for serializing an instance of the [Message] type.
16377 ///
16378 /// Can be created using the [Message::builder] method.
16379 #[derive(Debug)]
16380 #[must_use]
16381 pub struct MessageBuilder<State>(State);
16382
16383 impl MessageBuilder<()> {
16384 /// Setter for the [`version` field](Message#structfield.version).
16385 #[inline]
16386 #[allow(clippy::type_complexity)]
16387 pub fn version<T0>(self, value: T0) -> MessageBuilder<(T0,)>
16388 where
16389 T0: ::planus::WriteAsDefault<
16390 self::MetadataVersion,
16391 self::MetadataVersion,
16392 >,
16393 {
16394 MessageBuilder((value,))
16395 }
16396
16397 /// Sets the [`version` field](Message#structfield.version) to the default value.
16398 #[inline]
16399 #[allow(clippy::type_complexity)]
16400 pub fn version_as_default(
16401 self,
16402 ) -> MessageBuilder<(::planus::DefaultValue,)> {
16403 self.version(::planus::DefaultValue)
16404 }
16405 }
16406
16407 impl<T0> MessageBuilder<(T0,)> {
16408 /// Setter for the [`header` field](Message#structfield.header).
16409 #[inline]
16410 #[allow(clippy::type_complexity)]
16411 pub fn header<T1>(self, value: T1) -> MessageBuilder<(T0, T1)>
16412 where
16413 T1: ::planus::WriteAsOptionalUnion<self::MessageHeader>,
16414 {
16415 let (v0,) = self.0;
16416 MessageBuilder((v0, value))
16417 }
16418
16419 /// Sets the [`header` field](Message#structfield.header) to null.
16420 #[inline]
16421 #[allow(clippy::type_complexity)]
16422 pub fn header_as_null(self) -> MessageBuilder<(T0, ())> {
16423 self.header(())
16424 }
16425 }
16426
16427 impl<T0, T1> MessageBuilder<(T0, T1)> {
16428 /// Setter for the [`bodyLength` field](Message#structfield.body_length).
16429 #[inline]
16430 #[allow(clippy::type_complexity)]
16431 pub fn body_length<T2>(self, value: T2) -> MessageBuilder<(T0, T1, T2)>
16432 where
16433 T2: ::planus::WriteAsDefault<i64, i64>,
16434 {
16435 let (v0, v1) = self.0;
16436 MessageBuilder((v0, v1, value))
16437 }
16438
16439 /// Sets the [`bodyLength` field](Message#structfield.body_length) to the default value.
16440 #[inline]
16441 #[allow(clippy::type_complexity)]
16442 pub fn body_length_as_default(
16443 self,
16444 ) -> MessageBuilder<(T0, T1, ::planus::DefaultValue)>
16445 {
16446 self.body_length(::planus::DefaultValue)
16447 }
16448 }
16449
16450 impl<T0, T1, T2> MessageBuilder<(T0, T1, T2)> {
16451 /// Setter for the [`custom_metadata` field](Message#structfield.custom_metadata).
16452 #[inline]
16453 #[allow(clippy::type_complexity)]
16454 pub fn custom_metadata<T3>(
16455 self,
16456 value: T3,
16457 ) -> MessageBuilder<(T0, T1, T2, T3)>
16458 where
16459 T3: ::planus::WriteAsOptional<
16460 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
16461 >,
16462 {
16463 let (v0, v1, v2) = self.0;
16464 MessageBuilder((v0, v1, v2, value))
16465 }
16466
16467 /// Sets the [`custom_metadata` field](Message#structfield.custom_metadata) to null.
16468 #[inline]
16469 #[allow(clippy::type_complexity)]
16470 pub fn custom_metadata_as_null(self) -> MessageBuilder<(T0, T1, T2, ())> {
16471 self.custom_metadata(())
16472 }
16473 }
16474
16475 impl<T0, T1, T2, T3> MessageBuilder<(T0, T1, T2, T3)> {
16476 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Message].
16477 #[inline]
16478 pub fn finish(
16479 self,
16480 builder: &mut ::planus::Builder,
16481 ) -> ::planus::Offset<Message>
16482 where
16483 Self: ::planus::WriteAsOffset<Message>,
16484 {
16485 ::planus::WriteAsOffset::prepare(&self, builder)
16486 }
16487 }
16488
16489 impl<
16490 T0: ::planus::WriteAsDefault<self::MetadataVersion, self::MetadataVersion>,
16491 T1: ::planus::WriteAsOptionalUnion<self::MessageHeader>,
16492 T2: ::planus::WriteAsDefault<i64, i64>,
16493 T3: ::planus::WriteAsOptional<
16494 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
16495 >,
16496 > ::planus::WriteAs<::planus::Offset<Message>>
16497 for MessageBuilder<(T0, T1, T2, T3)>
16498 {
16499 type Prepared = ::planus::Offset<Message>;
16500
16501 #[inline]
16502 fn prepare(
16503 &self,
16504 builder: &mut ::planus::Builder,
16505 ) -> ::planus::Offset<Message> {
16506 ::planus::WriteAsOffset::prepare(self, builder)
16507 }
16508 }
16509
16510 impl<
16511 T0: ::planus::WriteAsDefault<self::MetadataVersion, self::MetadataVersion>,
16512 T1: ::planus::WriteAsOptionalUnion<self::MessageHeader>,
16513 T2: ::planus::WriteAsDefault<i64, i64>,
16514 T3: ::planus::WriteAsOptional<
16515 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
16516 >,
16517 > ::planus::WriteAsOptional<::planus::Offset<Message>>
16518 for MessageBuilder<(T0, T1, T2, T3)>
16519 {
16520 type Prepared = ::planus::Offset<Message>;
16521
16522 #[inline]
16523 fn prepare(
16524 &self,
16525 builder: &mut ::planus::Builder,
16526 ) -> ::core::option::Option<::planus::Offset<Message>>
16527 {
16528 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
16529 self, builder,
16530 ))
16531 }
16532 }
16533
16534 impl<
16535 T0: ::planus::WriteAsDefault<self::MetadataVersion, self::MetadataVersion>,
16536 T1: ::planus::WriteAsOptionalUnion<self::MessageHeader>,
16537 T2: ::planus::WriteAsDefault<i64, i64>,
16538 T3: ::planus::WriteAsOptional<
16539 ::planus::Offset<[::planus::Offset<self::KeyValue>]>,
16540 >,
16541 > ::planus::WriteAsOffset<Message> for MessageBuilder<(T0, T1, T2, T3)>
16542 {
16543 #[inline]
16544 fn prepare(
16545 &self,
16546 builder: &mut ::planus::Builder,
16547 ) -> ::planus::Offset<Message> {
16548 let (v0, v1, v2, v3) = &self.0;
16549 Message::create(builder, v0, v1, v2, v3)
16550 }
16551 }
16552
16553 /// Reference to a deserialized [Message].
16554 #[derive(Copy, Clone)]
16555 pub struct MessageRef<'a>(::planus::table_reader::Table<'a>);
16556
16557 impl<'a> MessageRef<'a> {
16558 /// Getter for the [`version` field](Message#structfield.version).
16559 #[inline]
16560 pub fn version(&self) -> ::planus::Result<self::MetadataVersion> {
16561 ::core::result::Result::Ok(
16562 self.0
16563 .access(0, "Message", "version")?
16564 .unwrap_or(self::MetadataVersion::V1),
16565 )
16566 }
16567
16568 /// Getter for the [`header` field](Message#structfield.header).
16569 #[inline]
16570 pub fn header(
16571 &self,
16572 ) -> ::planus::Result<::core::option::Option<self::MessageHeaderRef<'a>>>
16573 {
16574 self.0.access_union(1, "Message", "header")
16575 }
16576
16577 /// Getter for the [`bodyLength` field](Message#structfield.body_length).
16578 #[inline]
16579 pub fn body_length(&self) -> ::planus::Result<i64> {
16580 ::core::result::Result::Ok(
16581 self.0.access(3, "Message", "body_length")?.unwrap_or(0),
16582 )
16583 }
16584
16585 /// Getter for the [`custom_metadata` field](Message#structfield.custom_metadata).
16586 #[inline]
16587 pub fn custom_metadata(
16588 &self,
16589 ) -> ::planus::Result<
16590 ::core::option::Option<
16591 ::planus::Vector<'a, ::planus::Result<self::KeyValueRef<'a>>>,
16592 >,
16593 > {
16594 self.0.access(4, "Message", "custom_metadata")
16595 }
16596 }
16597
16598 impl<'a> ::core::fmt::Debug for MessageRef<'a> {
16599 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
16600 let mut f = f.debug_struct("MessageRef");
16601 f.field("version", &self.version());
16602 if let ::core::option::Option::Some(field_header) =
16603 self.header().transpose()
16604 {
16605 f.field("header", &field_header);
16606 }
16607 f.field("body_length", &self.body_length());
16608 if let ::core::option::Option::Some(field_custom_metadata) =
16609 self.custom_metadata().transpose()
16610 {
16611 f.field("custom_metadata", &field_custom_metadata);
16612 }
16613 f.finish()
16614 }
16615 }
16616
16617 impl<'a> ::core::convert::TryFrom<MessageRef<'a>> for Message {
16618 type Error = ::planus::Error;
16619
16620 #[allow(unreachable_code)]
16621 fn try_from(value: MessageRef<'a>) -> ::planus::Result<Self> {
16622 ::core::result::Result::Ok(Self {
16623 version: ::core::convert::TryInto::try_into(value.version()?)?,
16624 header: if let ::core::option::Option::Some(header) =
16625 value.header()?
16626 {
16627 ::core::option::Option::Some(
16628 ::core::convert::TryInto::try_into(header)?,
16629 )
16630 } else {
16631 ::core::option::Option::None
16632 },
16633 body_length: ::core::convert::TryInto::try_into(
16634 value.body_length()?,
16635 )?,
16636 custom_metadata: if let ::core::option::Option::Some(
16637 custom_metadata,
16638 ) = value.custom_metadata()?
16639 {
16640 ::core::option::Option::Some(custom_metadata.to_vec_result()?)
16641 } else {
16642 ::core::option::Option::None
16643 },
16644 })
16645 }
16646 }
16647
16648 impl<'a> ::planus::TableRead<'a> for MessageRef<'a> {
16649 #[inline]
16650 fn from_buffer(
16651 buffer: ::planus::SliceWithStartOffset<'a>,
16652 offset: usize,
16653 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
16654 {
16655 ::core::result::Result::Ok(Self(
16656 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
16657 ))
16658 }
16659 }
16660
16661 impl<'a> ::planus::VectorReadInner<'a> for MessageRef<'a> {
16662 type Error = ::planus::Error;
16663 const STRIDE: usize = 4;
16664
16665 unsafe fn from_buffer(
16666 buffer: ::planus::SliceWithStartOffset<'a>,
16667 offset: usize,
16668 ) -> ::planus::Result<Self> {
16669 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
16670 error_kind.with_error_location(
16671 "[MessageRef]",
16672 "get",
16673 buffer.offset_from_start,
16674 )
16675 })
16676 }
16677 }
16678
16679 /// # Safety
16680 /// The planus compiler generates implementations that initialize
16681 /// the bytes in `write_values`.
16682 unsafe impl ::planus::VectorWrite<::planus::Offset<Message>> for Message {
16683 type Value = ::planus::Offset<Message>;
16684 const STRIDE: usize = 4;
16685 #[inline]
16686 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
16687 ::planus::WriteAs::prepare(self, builder)
16688 }
16689
16690 #[inline]
16691 unsafe fn write_values(
16692 values: &[::planus::Offset<Message>],
16693 bytes: *mut ::core::mem::MaybeUninit<u8>,
16694 buffer_position: u32,
16695 ) {
16696 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
16697 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
16698 ::planus::WriteAsPrimitive::write(
16699 v,
16700 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
16701 buffer_position - (Self::STRIDE * i) as u32,
16702 );
16703 }
16704 }
16705 }
16706
16707 impl<'a> ::planus::ReadAsRoot<'a> for MessageRef<'a> {
16708 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
16709 ::planus::TableRead::from_buffer(
16710 ::planus::SliceWithStartOffset {
16711 buffer: slice,
16712 offset_from_start: 0,
16713 },
16714 0,
16715 )
16716 .map_err(|error_kind| {
16717 error_kind.with_error_location("[MessageRef]", "read_as_root", 0)
16718 })
16719 }
16720 }
16721
16722 /// ----------------------------------------------------------------------
16723 /// EXPERIMENTAL: Data structures for sparse tensors
16724 /// Coordinate (COO) format of sparse tensor index.
16725 ///
16726 /// COO's index list are represented as a NxM matrix,
16727 /// where N is the number of non-zero values,
16728 /// and M is the number of dimensions of a sparse tensor.
16729 ///
16730 /// indicesBuffer stores the location and size of the data of this indices
16731 /// matrix. The value type and the stride of the indices matrix is
16732 /// specified in indicesType and indicesStrides fields.
16733 ///
16734 /// For example, let X be a 2x3x4x5 tensor, and it has the following
16735 /// 6 non-zero values:
16736 /// ```text
16737 /// X[0, 1, 2, 0] := 1
16738 /// X[1, 1, 2, 3] := 2
16739 /// X[0, 2, 1, 0] := 3
16740 /// X[0, 1, 3, 0] := 4
16741 /// X[0, 1, 2, 1] := 5
16742 /// X[1, 2, 0, 4] := 6
16743 /// ```
16744 /// In COO format, the index matrix of X is the following 4x6 matrix:
16745 /// ```text
16746 /// [[0, 0, 0, 0, 1, 1],
16747 /// [1, 1, 1, 2, 1, 2],
16748 /// [2, 2, 3, 1, 2, 0],
16749 /// [0, 1, 0, 0, 3, 4]]
16750 /// ```
16751 /// When isCanonical is true, the indices is sorted in lexicographical order
16752 /// (row-major order), and it does not have duplicated entries. Otherwise,
16753 /// the indices may not be sorted, or may have duplicated entries.
16754 ///
16755 /// Generated from these locations:
16756 /// * Table `SparseTensorIndexCOO` in the file `SparseTensor.fbs:58`
16757 #[derive(
16758 Clone,
16759 Debug,
16760 PartialEq,
16761 PartialOrd,
16762 Eq,
16763 Ord,
16764 Hash,
16765 ::serde::Serialize,
16766 ::serde::Deserialize,
16767 )]
16768 pub struct SparseTensorIndexCoo {
16769 /// The type of values in indicesBuffer
16770 pub indices_type: ::planus::alloc::boxed::Box<self::Int>,
16771 /// Non-negative byte offsets to advance one value cell along each dimension
16772 /// If omitted, default to row-major order (C-like).
16773 pub indices_strides: ::core::option::Option<::planus::alloc::vec::Vec<i64>>,
16774 /// The location and size of the indices matrix's data
16775 pub indices_buffer: self::Buffer,
16776 /// This flag is true if and only if the indices matrix is sorted in
16777 /// row-major order, and does not have duplicated entries.
16778 /// This sort order is the same as of Tensorflow's SparseTensor,
16779 /// but it is inverse order of SciPy's canonical coo_matrix
16780 /// (SciPy employs column-major order for its coo_matrix).
16781 pub is_canonical: bool,
16782 }
16783
16784 #[allow(clippy::derivable_impls)]
16785 impl ::core::default::Default for SparseTensorIndexCoo {
16786 fn default() -> Self {
16787 Self {
16788 indices_type: ::core::default::Default::default(),
16789 indices_strides: ::core::default::Default::default(),
16790 indices_buffer: ::core::default::Default::default(),
16791 is_canonical: false,
16792 }
16793 }
16794 }
16795
16796 impl SparseTensorIndexCoo {
16797 /// Creates a [SparseTensorIndexCooBuilder] for serializing an instance of this table.
16798 #[inline]
16799 pub fn builder() -> SparseTensorIndexCooBuilder<()> {
16800 SparseTensorIndexCooBuilder(())
16801 }
16802
16803 #[allow(clippy::too_many_arguments)]
16804 pub fn create(
16805 builder: &mut ::planus::Builder,
16806 field_indices_type: impl ::planus::WriteAs<::planus::Offset<self::Int>>,
16807 field_indices_strides: impl ::planus::WriteAsOptional<
16808 ::planus::Offset<[i64]>,
16809 >,
16810 field_indices_buffer: impl ::planus::WriteAs<self::Buffer>,
16811 field_is_canonical: impl ::planus::WriteAsDefault<bool, bool>,
16812 ) -> ::planus::Offset<Self> {
16813 let prepared_indices_type = field_indices_type.prepare(builder);
16814 let prepared_indices_strides = field_indices_strides.prepare(builder);
16815 let prepared_indices_buffer = field_indices_buffer.prepare(builder);
16816 let prepared_is_canonical = field_is_canonical.prepare(builder, &false);
16817
16818 let mut table_writer: ::planus::table_writer::TableWriter<12> =
16819 ::core::default::Default::default();
16820 table_writer.write_entry::<self::Buffer>(2);
16821 table_writer.write_entry::<::planus::Offset<self::Int>>(0);
16822 if prepared_indices_strides.is_some() {
16823 table_writer.write_entry::<::planus::Offset<[i64]>>(1);
16824 }
16825 if prepared_is_canonical.is_some() {
16826 table_writer.write_entry::<bool>(3);
16827 }
16828
16829 unsafe {
16830 table_writer.finish(builder, |object_writer| {
16831 object_writer.write::<_, _, 16>(&prepared_indices_buffer);
16832 object_writer.write::<_, _, 4>(&prepared_indices_type);
16833 if let ::core::option::Option::Some(prepared_indices_strides) =
16834 prepared_indices_strides
16835 {
16836 object_writer.write::<_, _, 4>(&prepared_indices_strides);
16837 }
16838 if let ::core::option::Option::Some(prepared_is_canonical) =
16839 prepared_is_canonical
16840 {
16841 object_writer.write::<_, _, 1>(&prepared_is_canonical);
16842 }
16843 });
16844 }
16845 builder.current_offset()
16846 }
16847 }
16848
16849 impl ::planus::WriteAs<::planus::Offset<SparseTensorIndexCoo>> for SparseTensorIndexCoo {
16850 type Prepared = ::planus::Offset<Self>;
16851
16852 #[inline]
16853 fn prepare(
16854 &self,
16855 builder: &mut ::planus::Builder,
16856 ) -> ::planus::Offset<SparseTensorIndexCoo> {
16857 ::planus::WriteAsOffset::prepare(self, builder)
16858 }
16859 }
16860
16861 impl ::planus::WriteAsOptional<::planus::Offset<SparseTensorIndexCoo>> for SparseTensorIndexCoo {
16862 type Prepared = ::planus::Offset<Self>;
16863
16864 #[inline]
16865 fn prepare(
16866 &self,
16867 builder: &mut ::planus::Builder,
16868 ) -> ::core::option::Option<::planus::Offset<SparseTensorIndexCoo>>
16869 {
16870 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
16871 self, builder,
16872 ))
16873 }
16874 }
16875
16876 impl ::planus::WriteAsOffset<SparseTensorIndexCoo> for SparseTensorIndexCoo {
16877 #[inline]
16878 fn prepare(
16879 &self,
16880 builder: &mut ::planus::Builder,
16881 ) -> ::planus::Offset<SparseTensorIndexCoo> {
16882 SparseTensorIndexCoo::create(
16883 builder,
16884 &self.indices_type,
16885 &self.indices_strides,
16886 self.indices_buffer,
16887 self.is_canonical,
16888 )
16889 }
16890 }
16891
16892 /// Builder for serializing an instance of the [SparseTensorIndexCoo] type.
16893 ///
16894 /// Can be created using the [SparseTensorIndexCoo::builder] method.
16895 #[derive(Debug)]
16896 #[must_use]
16897 pub struct SparseTensorIndexCooBuilder<State>(State);
16898
16899 impl SparseTensorIndexCooBuilder<()> {
16900 /// Setter for the [`indicesType` field](SparseTensorIndexCoo#structfield.indices_type).
16901 #[inline]
16902 #[allow(clippy::type_complexity)]
16903 pub fn indices_type<T0>(
16904 self,
16905 value: T0,
16906 ) -> SparseTensorIndexCooBuilder<(T0,)>
16907 where
16908 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
16909 {
16910 SparseTensorIndexCooBuilder((value,))
16911 }
16912 }
16913
16914 impl<T0> SparseTensorIndexCooBuilder<(T0,)> {
16915 /// Setter for the [`indicesStrides` field](SparseTensorIndexCoo#structfield.indices_strides).
16916 #[inline]
16917 #[allow(clippy::type_complexity)]
16918 pub fn indices_strides<T1>(
16919 self,
16920 value: T1,
16921 ) -> SparseTensorIndexCooBuilder<(T0, T1)>
16922 where
16923 T1: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
16924 {
16925 let (v0,) = self.0;
16926 SparseTensorIndexCooBuilder((v0, value))
16927 }
16928
16929 /// Sets the [`indicesStrides` field](SparseTensorIndexCoo#structfield.indices_strides) to null.
16930 #[inline]
16931 #[allow(clippy::type_complexity)]
16932 pub fn indices_strides_as_null(
16933 self,
16934 ) -> SparseTensorIndexCooBuilder<(T0, ())> {
16935 self.indices_strides(())
16936 }
16937 }
16938
16939 impl<T0, T1> SparseTensorIndexCooBuilder<(T0, T1)> {
16940 /// Setter for the [`indicesBuffer` field](SparseTensorIndexCoo#structfield.indices_buffer).
16941 #[inline]
16942 #[allow(clippy::type_complexity)]
16943 pub fn indices_buffer<T2>(
16944 self,
16945 value: T2,
16946 ) -> SparseTensorIndexCooBuilder<(T0, T1, T2)>
16947 where
16948 T2: ::planus::WriteAs<self::Buffer>,
16949 {
16950 let (v0, v1) = self.0;
16951 SparseTensorIndexCooBuilder((v0, v1, value))
16952 }
16953 }
16954
16955 impl<T0, T1, T2> SparseTensorIndexCooBuilder<(T0, T1, T2)> {
16956 /// Setter for the [`isCanonical` field](SparseTensorIndexCoo#structfield.is_canonical).
16957 #[inline]
16958 #[allow(clippy::type_complexity)]
16959 pub fn is_canonical<T3>(
16960 self,
16961 value: T3,
16962 ) -> SparseTensorIndexCooBuilder<(T0, T1, T2, T3)>
16963 where
16964 T3: ::planus::WriteAsDefault<bool, bool>,
16965 {
16966 let (v0, v1, v2) = self.0;
16967 SparseTensorIndexCooBuilder((v0, v1, v2, value))
16968 }
16969
16970 /// Sets the [`isCanonical` field](SparseTensorIndexCoo#structfield.is_canonical) to the default value.
16971 #[inline]
16972 #[allow(clippy::type_complexity)]
16973 pub fn is_canonical_as_default(
16974 self,
16975 ) -> SparseTensorIndexCooBuilder<(T0, T1, T2, ::planus::DefaultValue)>
16976 {
16977 self.is_canonical(::planus::DefaultValue)
16978 }
16979 }
16980
16981 impl<T0, T1, T2, T3> SparseTensorIndexCooBuilder<(T0, T1, T2, T3)> {
16982 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SparseTensorIndexCoo].
16983 #[inline]
16984 pub fn finish(
16985 self,
16986 builder: &mut ::planus::Builder,
16987 ) -> ::planus::Offset<SparseTensorIndexCoo>
16988 where
16989 Self: ::planus::WriteAsOffset<SparseTensorIndexCoo>,
16990 {
16991 ::planus::WriteAsOffset::prepare(&self, builder)
16992 }
16993 }
16994
16995 impl<
16996 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
16997 T1: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
16998 T2: ::planus::WriteAs<self::Buffer>,
16999 T3: ::planus::WriteAsDefault<bool, bool>,
17000 >
17001 ::planus::WriteAs<::planus::Offset<SparseTensorIndexCoo>>
17002 for SparseTensorIndexCooBuilder<(T0, T1, T2, T3)>
17003 {
17004 type Prepared = ::planus::Offset<SparseTensorIndexCoo>;
17005
17006 #[inline]
17007 fn prepare(
17008 &self,
17009 builder: &mut ::planus::Builder,
17010 ) -> ::planus::Offset<SparseTensorIndexCoo> {
17011 ::planus::WriteAsOffset::prepare(self, builder)
17012 }
17013 }
17014
17015 impl<
17016 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
17017 T1: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
17018 T2: ::planus::WriteAs<self::Buffer>,
17019 T3: ::planus::WriteAsDefault<bool, bool>,
17020 >
17021 ::planus::WriteAsOptional<::planus::Offset<SparseTensorIndexCoo>>
17022 for SparseTensorIndexCooBuilder<(T0, T1, T2, T3)>
17023 {
17024 type Prepared = ::planus::Offset<SparseTensorIndexCoo>;
17025
17026 #[inline]
17027 fn prepare(
17028 &self,
17029 builder: &mut ::planus::Builder,
17030 ) -> ::core::option::Option<::planus::Offset<SparseTensorIndexCoo>>
17031 {
17032 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
17033 self, builder,
17034 ))
17035 }
17036 }
17037
17038 impl<
17039 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
17040 T1: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
17041 T2: ::planus::WriteAs<self::Buffer>,
17042 T3: ::planus::WriteAsDefault<bool, bool>,
17043 > ::planus::WriteAsOffset<SparseTensorIndexCoo>
17044 for SparseTensorIndexCooBuilder<(T0, T1, T2, T3)>
17045 {
17046 #[inline]
17047 fn prepare(
17048 &self,
17049 builder: &mut ::planus::Builder,
17050 ) -> ::planus::Offset<SparseTensorIndexCoo> {
17051 let (v0, v1, v2, v3) = &self.0;
17052 SparseTensorIndexCoo::create(builder, v0, v1, v2, v3)
17053 }
17054 }
17055
17056 /// Reference to a deserialized [SparseTensorIndexCoo].
17057 #[derive(Copy, Clone)]
17058 pub struct SparseTensorIndexCooRef<'a>(::planus::table_reader::Table<'a>);
17059
17060 impl<'a> SparseTensorIndexCooRef<'a> {
17061 /// Getter for the [`indicesType` field](SparseTensorIndexCoo#structfield.indices_type).
17062 #[inline]
17063 pub fn indices_type(&self) -> ::planus::Result<self::IntRef<'a>> {
17064 self.0
17065 .access_required(0, "SparseTensorIndexCoo", "indices_type")
17066 }
17067
17068 /// Getter for the [`indicesStrides` field](SparseTensorIndexCoo#structfield.indices_strides).
17069 #[inline]
17070 pub fn indices_strides(
17071 &self,
17072 ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i64>>>
17073 {
17074 self.0.access(1, "SparseTensorIndexCoo", "indices_strides")
17075 }
17076
17077 /// Getter for the [`indicesBuffer` field](SparseTensorIndexCoo#structfield.indices_buffer).
17078 #[inline]
17079 pub fn indices_buffer(&self) -> ::planus::Result<self::BufferRef<'a>> {
17080 self.0
17081 .access_required(2, "SparseTensorIndexCoo", "indices_buffer")
17082 }
17083
17084 /// Getter for the [`isCanonical` field](SparseTensorIndexCoo#structfield.is_canonical).
17085 #[inline]
17086 pub fn is_canonical(&self) -> ::planus::Result<bool> {
17087 ::core::result::Result::Ok(
17088 self.0
17089 .access(3, "SparseTensorIndexCoo", "is_canonical")?
17090 .unwrap_or(false),
17091 )
17092 }
17093 }
17094
17095 impl<'a> ::core::fmt::Debug for SparseTensorIndexCooRef<'a> {
17096 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
17097 let mut f = f.debug_struct("SparseTensorIndexCooRef");
17098 f.field("indices_type", &self.indices_type());
17099 if let ::core::option::Option::Some(field_indices_strides) =
17100 self.indices_strides().transpose()
17101 {
17102 f.field("indices_strides", &field_indices_strides);
17103 }
17104 f.field("indices_buffer", &self.indices_buffer());
17105 f.field("is_canonical", &self.is_canonical());
17106 f.finish()
17107 }
17108 }
17109
17110 impl<'a> ::core::convert::TryFrom<SparseTensorIndexCooRef<'a>> for SparseTensorIndexCoo {
17111 type Error = ::planus::Error;
17112
17113 #[allow(unreachable_code)]
17114 fn try_from(value: SparseTensorIndexCooRef<'a>) -> ::planus::Result<Self> {
17115 ::core::result::Result::Ok(Self {
17116 indices_type: ::planus::alloc::boxed::Box::new(
17117 ::core::convert::TryInto::try_into(value.indices_type()?)?,
17118 ),
17119 indices_strides: if let ::core::option::Option::Some(
17120 indices_strides,
17121 ) = value.indices_strides()?
17122 {
17123 ::core::option::Option::Some(indices_strides.to_vec()?)
17124 } else {
17125 ::core::option::Option::None
17126 },
17127 indices_buffer: ::core::convert::Into::into(
17128 value.indices_buffer()?,
17129 ),
17130 is_canonical: ::core::convert::TryInto::try_into(
17131 value.is_canonical()?,
17132 )?,
17133 })
17134 }
17135 }
17136
17137 impl<'a> ::planus::TableRead<'a> for SparseTensorIndexCooRef<'a> {
17138 #[inline]
17139 fn from_buffer(
17140 buffer: ::planus::SliceWithStartOffset<'a>,
17141 offset: usize,
17142 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
17143 {
17144 ::core::result::Result::Ok(Self(
17145 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
17146 ))
17147 }
17148 }
17149
17150 impl<'a> ::planus::VectorReadInner<'a> for SparseTensorIndexCooRef<'a> {
17151 type Error = ::planus::Error;
17152 const STRIDE: usize = 4;
17153
17154 unsafe fn from_buffer(
17155 buffer: ::planus::SliceWithStartOffset<'a>,
17156 offset: usize,
17157 ) -> ::planus::Result<Self> {
17158 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
17159 error_kind.with_error_location(
17160 "[SparseTensorIndexCooRef]",
17161 "get",
17162 buffer.offset_from_start,
17163 )
17164 })
17165 }
17166 }
17167
17168 /// # Safety
17169 /// The planus compiler generates implementations that initialize
17170 /// the bytes in `write_values`.
17171 unsafe impl ::planus::VectorWrite<::planus::Offset<SparseTensorIndexCoo>> for SparseTensorIndexCoo {
17172 type Value = ::planus::Offset<SparseTensorIndexCoo>;
17173 const STRIDE: usize = 4;
17174 #[inline]
17175 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
17176 ::planus::WriteAs::prepare(self, builder)
17177 }
17178
17179 #[inline]
17180 unsafe fn write_values(
17181 values: &[::planus::Offset<SparseTensorIndexCoo>],
17182 bytes: *mut ::core::mem::MaybeUninit<u8>,
17183 buffer_position: u32,
17184 ) {
17185 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
17186 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
17187 ::planus::WriteAsPrimitive::write(
17188 v,
17189 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
17190 buffer_position - (Self::STRIDE * i) as u32,
17191 );
17192 }
17193 }
17194 }
17195
17196 impl<'a> ::planus::ReadAsRoot<'a> for SparseTensorIndexCooRef<'a> {
17197 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
17198 ::planus::TableRead::from_buffer(
17199 ::planus::SliceWithStartOffset {
17200 buffer: slice,
17201 offset_from_start: 0,
17202 },
17203 0,
17204 )
17205 .map_err(|error_kind| {
17206 error_kind.with_error_location(
17207 "[SparseTensorIndexCooRef]",
17208 "read_as_root",
17209 0,
17210 )
17211 })
17212 }
17213 }
17214
17215 /// The enum `SparseMatrixCompressedAxis` in the namespace `org.apache.arrow.flatbuf`
17216 ///
17217 /// Generated from these locations:
17218 /// * Enum `SparseMatrixCompressedAxis` in the file `SparseTensor.fbs:77`
17219 #[derive(
17220 Copy,
17221 Clone,
17222 Debug,
17223 PartialEq,
17224 Eq,
17225 PartialOrd,
17226 Ord,
17227 Hash,
17228 ::serde::Serialize,
17229 ::serde::Deserialize,
17230 )]
17231 #[repr(i16)]
17232 pub enum SparseMatrixCompressedAxis {
17233 /// The variant `Row` in the enum `SparseMatrixCompressedAxis`
17234 Row = 0,
17235
17236 /// The variant `Column` in the enum `SparseMatrixCompressedAxis`
17237 Column = 1,
17238 }
17239
17240 impl SparseMatrixCompressedAxis {
17241 /// Array containing all valid variants of SparseMatrixCompressedAxis
17242 pub const ENUM_VALUES: [Self; 2] = [Self::Row, Self::Column];
17243 }
17244
17245 impl ::core::convert::TryFrom<i16> for SparseMatrixCompressedAxis {
17246 type Error = ::planus::errors::UnknownEnumTagKind;
17247 #[inline]
17248 fn try_from(
17249 value: i16,
17250 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTagKind>
17251 {
17252 #[allow(clippy::match_single_binding)]
17253 match value {
17254 0 => ::core::result::Result::Ok(SparseMatrixCompressedAxis::Row),
17255 1 => ::core::result::Result::Ok(SparseMatrixCompressedAxis::Column),
17256
17257 _ => ::core::result::Result::Err(
17258 ::planus::errors::UnknownEnumTagKind { tag: value as i128 },
17259 ),
17260 }
17261 }
17262 }
17263
17264 impl ::core::convert::From<SparseMatrixCompressedAxis> for i16 {
17265 #[inline]
17266 fn from(value: SparseMatrixCompressedAxis) -> Self {
17267 value as i16
17268 }
17269 }
17270
17271 /// # Safety
17272 /// The Planus compiler correctly calculates `ALIGNMENT` and `SIZE`.
17273 unsafe impl ::planus::Primitive for SparseMatrixCompressedAxis {
17274 const ALIGNMENT: usize = 2;
17275 const SIZE: usize = 2;
17276 }
17277
17278 impl ::planus::WriteAsPrimitive<SparseMatrixCompressedAxis> for SparseMatrixCompressedAxis {
17279 #[inline]
17280 fn write<const N: usize>(
17281 &self,
17282 cursor: ::planus::Cursor<'_, N>,
17283 buffer_position: u32,
17284 ) {
17285 (*self as i16).write(cursor, buffer_position);
17286 }
17287 }
17288
17289 impl ::planus::WriteAs<SparseMatrixCompressedAxis> for SparseMatrixCompressedAxis {
17290 type Prepared = Self;
17291
17292 #[inline]
17293 fn prepare(
17294 &self,
17295 _builder: &mut ::planus::Builder,
17296 ) -> SparseMatrixCompressedAxis {
17297 *self
17298 }
17299 }
17300
17301 impl
17302 ::planus::WriteAsDefault<
17303 SparseMatrixCompressedAxis,
17304 SparseMatrixCompressedAxis,
17305 > for SparseMatrixCompressedAxis
17306 {
17307 type Prepared = Self;
17308
17309 #[inline]
17310 fn prepare(
17311 &self,
17312 _builder: &mut ::planus::Builder,
17313 default: &SparseMatrixCompressedAxis,
17314 ) -> ::core::option::Option<SparseMatrixCompressedAxis>
17315 {
17316 if self == default {
17317 ::core::option::Option::None
17318 } else {
17319 ::core::option::Option::Some(*self)
17320 }
17321 }
17322 }
17323
17324 impl ::planus::WriteAsOptional<SparseMatrixCompressedAxis> for SparseMatrixCompressedAxis {
17325 type Prepared = Self;
17326
17327 #[inline]
17328 fn prepare(
17329 &self,
17330 _builder: &mut ::planus::Builder,
17331 ) -> ::core::option::Option<SparseMatrixCompressedAxis>
17332 {
17333 ::core::option::Option::Some(*self)
17334 }
17335 }
17336
17337 impl<'buf> ::planus::TableRead<'buf> for SparseMatrixCompressedAxis {
17338 #[inline]
17339 fn from_buffer(
17340 buffer: ::planus::SliceWithStartOffset<'buf>,
17341 offset: usize,
17342 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
17343 {
17344 let n: i16 = ::planus::TableRead::from_buffer(buffer, offset)?;
17345 ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?)
17346 }
17347 }
17348
17349 impl<'buf> ::planus::VectorReadInner<'buf> for SparseMatrixCompressedAxis {
17350 type Error = ::planus::errors::UnknownEnumTag;
17351 const STRIDE: usize = 2;
17352 #[inline]
17353 unsafe fn from_buffer(
17354 buffer: ::planus::SliceWithStartOffset<'buf>,
17355 offset: usize,
17356 ) -> ::core::result::Result<Self, ::planus::errors::UnknownEnumTag>
17357 {
17358 let value = unsafe {
17359 <i16 as ::planus::VectorRead>::from_buffer(buffer, offset)
17360 };
17361 let value: ::core::result::Result<Self, _> =
17362 ::core::convert::TryInto::try_into(value);
17363 value.map_err(|error_kind| {
17364 error_kind.with_error_location(
17365 "SparseMatrixCompressedAxis",
17366 "VectorRead::from_buffer",
17367 buffer.offset_from_start,
17368 )
17369 })
17370 }
17371 }
17372
17373 /// # Safety
17374 /// The planus compiler generates implementations that initialize
17375 /// the bytes in `write_values`.
17376 unsafe impl ::planus::VectorWrite<SparseMatrixCompressedAxis> for SparseMatrixCompressedAxis {
17377 const STRIDE: usize = 2;
17378
17379 type Value = Self;
17380
17381 #[inline]
17382 fn prepare(&self, _builder: &mut ::planus::Builder) -> Self {
17383 *self
17384 }
17385
17386 #[inline]
17387 unsafe fn write_values(
17388 values: &[Self],
17389 bytes: *mut ::core::mem::MaybeUninit<u8>,
17390 buffer_position: u32,
17391 ) {
17392 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 2];
17393 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
17394 ::planus::WriteAsPrimitive::write(
17395 v,
17396 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
17397 buffer_position - (2 * i) as u32,
17398 );
17399 }
17400 }
17401 }
17402
17403 /// Compressed Sparse format, that is matrix-specific.
17404 ///
17405 /// Generated from these locations:
17406 /// * Table `SparseMatrixIndexCSX` in the file `SparseTensor.fbs:80`
17407 #[derive(
17408 Clone,
17409 Debug,
17410 PartialEq,
17411 PartialOrd,
17412 Eq,
17413 Ord,
17414 Hash,
17415 ::serde::Serialize,
17416 ::serde::Deserialize,
17417 )]
17418 pub struct SparseMatrixIndexCsx {
17419 /// Which axis, row or column, is compressed
17420 pub compressed_axis: self::SparseMatrixCompressedAxis,
17421 /// The type of values in indptrBuffer
17422 pub indptr_type: ::planus::alloc::boxed::Box<self::Int>,
17423 /// indptrBuffer stores the location and size of indptr array that
17424 /// represents the range of the rows.
17425 /// The i-th row spans from `indptr[i]` to `indptr[i+1]` in the data.
17426 /// The length of this array is 1 + (the number of rows), and the type
17427 /// of index value is long.
17428 ///
17429 /// For example, let X be the following 6x4 matrix:
17430 /// ```text
17431 /// X := [[0, 1, 2, 0],
17432 /// [0, 0, 3, 0],
17433 /// [0, 4, 0, 5],
17434 /// [0, 0, 0, 0],
17435 /// [6, 0, 7, 8],
17436 /// [0, 9, 0, 0]].
17437 /// ```
17438 /// The array of non-zero values in X is:
17439 /// ```text
17440 /// values(X) = [1, 2, 3, 4, 5, 6, 7, 8, 9].
17441 /// ```
17442 /// And the indptr of X is:
17443 /// ```text
17444 /// indptr(X) = [0, 2, 3, 5, 5, 8, 10].
17445 /// ```
17446 pub indptr_buffer: self::Buffer,
17447 /// The type of values in indicesBuffer
17448 pub indices_type: ::planus::alloc::boxed::Box<self::Int>,
17449 /// indicesBuffer stores the location and size of the array that
17450 /// contains the column indices of the corresponding non-zero values.
17451 /// The type of index value is long.
17452 ///
17453 /// For example, the indices of the above X is:
17454 /// ```text
17455 /// indices(X) = [1, 2, 2, 1, 3, 0, 2, 3, 1].
17456 /// ```
17457 /// Note that the indices are sorted in lexicographical order for each row.
17458 pub indices_buffer: self::Buffer,
17459 }
17460
17461 #[allow(clippy::derivable_impls)]
17462 impl ::core::default::Default for SparseMatrixIndexCsx {
17463 fn default() -> Self {
17464 Self {
17465 compressed_axis: self::SparseMatrixCompressedAxis::Row,
17466 indptr_type: ::core::default::Default::default(),
17467 indptr_buffer: ::core::default::Default::default(),
17468 indices_type: ::core::default::Default::default(),
17469 indices_buffer: ::core::default::Default::default(),
17470 }
17471 }
17472 }
17473
17474 impl SparseMatrixIndexCsx {
17475 /// Creates a [SparseMatrixIndexCsxBuilder] for serializing an instance of this table.
17476 #[inline]
17477 pub fn builder() -> SparseMatrixIndexCsxBuilder<()> {
17478 SparseMatrixIndexCsxBuilder(())
17479 }
17480
17481 #[allow(clippy::too_many_arguments)]
17482 pub fn create(
17483 builder: &mut ::planus::Builder,
17484 field_compressed_axis: impl ::planus::WriteAsDefault<
17485 self::SparseMatrixCompressedAxis,
17486 self::SparseMatrixCompressedAxis,
17487 >,
17488 field_indptr_type: impl ::planus::WriteAs<::planus::Offset<self::Int>>,
17489 field_indptr_buffer: impl ::planus::WriteAs<self::Buffer>,
17490 field_indices_type: impl ::planus::WriteAs<::planus::Offset<self::Int>>,
17491 field_indices_buffer: impl ::planus::WriteAs<self::Buffer>,
17492 ) -> ::planus::Offset<Self> {
17493 let prepared_compressed_axis = field_compressed_axis
17494 .prepare(builder, &self::SparseMatrixCompressedAxis::Row);
17495 let prepared_indptr_type = field_indptr_type.prepare(builder);
17496 let prepared_indptr_buffer = field_indptr_buffer.prepare(builder);
17497 let prepared_indices_type = field_indices_type.prepare(builder);
17498 let prepared_indices_buffer = field_indices_buffer.prepare(builder);
17499
17500 let mut table_writer: ::planus::table_writer::TableWriter<14> =
17501 ::core::default::Default::default();
17502 table_writer.write_entry::<self::Buffer>(2);
17503 table_writer.write_entry::<self::Buffer>(4);
17504 table_writer.write_entry::<::planus::Offset<self::Int>>(1);
17505 table_writer.write_entry::<::planus::Offset<self::Int>>(3);
17506 if prepared_compressed_axis.is_some() {
17507 table_writer.write_entry::<self::SparseMatrixCompressedAxis>(0);
17508 }
17509
17510 unsafe {
17511 table_writer.finish(builder, |object_writer| {
17512 object_writer.write::<_, _, 16>(&prepared_indptr_buffer);
17513 object_writer.write::<_, _, 16>(&prepared_indices_buffer);
17514 object_writer.write::<_, _, 4>(&prepared_indptr_type);
17515 object_writer.write::<_, _, 4>(&prepared_indices_type);
17516 if let ::core::option::Option::Some(prepared_compressed_axis) =
17517 prepared_compressed_axis
17518 {
17519 object_writer.write::<_, _, 2>(&prepared_compressed_axis);
17520 }
17521 });
17522 }
17523 builder.current_offset()
17524 }
17525 }
17526
17527 impl ::planus::WriteAs<::planus::Offset<SparseMatrixIndexCsx>> for SparseMatrixIndexCsx {
17528 type Prepared = ::planus::Offset<Self>;
17529
17530 #[inline]
17531 fn prepare(
17532 &self,
17533 builder: &mut ::planus::Builder,
17534 ) -> ::planus::Offset<SparseMatrixIndexCsx> {
17535 ::planus::WriteAsOffset::prepare(self, builder)
17536 }
17537 }
17538
17539 impl ::planus::WriteAsOptional<::planus::Offset<SparseMatrixIndexCsx>> for SparseMatrixIndexCsx {
17540 type Prepared = ::planus::Offset<Self>;
17541
17542 #[inline]
17543 fn prepare(
17544 &self,
17545 builder: &mut ::planus::Builder,
17546 ) -> ::core::option::Option<::planus::Offset<SparseMatrixIndexCsx>>
17547 {
17548 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
17549 self, builder,
17550 ))
17551 }
17552 }
17553
17554 impl ::planus::WriteAsOffset<SparseMatrixIndexCsx> for SparseMatrixIndexCsx {
17555 #[inline]
17556 fn prepare(
17557 &self,
17558 builder: &mut ::planus::Builder,
17559 ) -> ::planus::Offset<SparseMatrixIndexCsx> {
17560 SparseMatrixIndexCsx::create(
17561 builder,
17562 self.compressed_axis,
17563 &self.indptr_type,
17564 self.indptr_buffer,
17565 &self.indices_type,
17566 self.indices_buffer,
17567 )
17568 }
17569 }
17570
17571 /// Builder for serializing an instance of the [SparseMatrixIndexCsx] type.
17572 ///
17573 /// Can be created using the [SparseMatrixIndexCsx::builder] method.
17574 #[derive(Debug)]
17575 #[must_use]
17576 pub struct SparseMatrixIndexCsxBuilder<State>(State);
17577
17578 impl SparseMatrixIndexCsxBuilder<()> {
17579 /// Setter for the [`compressedAxis` field](SparseMatrixIndexCsx#structfield.compressed_axis).
17580 #[inline]
17581 #[allow(clippy::type_complexity)]
17582 pub fn compressed_axis<T0>(
17583 self,
17584 value: T0,
17585 ) -> SparseMatrixIndexCsxBuilder<(T0,)>
17586 where
17587 T0: ::planus::WriteAsDefault<
17588 self::SparseMatrixCompressedAxis,
17589 self::SparseMatrixCompressedAxis,
17590 >,
17591 {
17592 SparseMatrixIndexCsxBuilder((value,))
17593 }
17594
17595 /// Sets the [`compressedAxis` field](SparseMatrixIndexCsx#structfield.compressed_axis) to the default value.
17596 #[inline]
17597 #[allow(clippy::type_complexity)]
17598 pub fn compressed_axis_as_default(
17599 self,
17600 ) -> SparseMatrixIndexCsxBuilder<(::planus::DefaultValue,)>
17601 {
17602 self.compressed_axis(::planus::DefaultValue)
17603 }
17604 }
17605
17606 impl<T0> SparseMatrixIndexCsxBuilder<(T0,)> {
17607 /// Setter for the [`indptrType` field](SparseMatrixIndexCsx#structfield.indptr_type).
17608 #[inline]
17609 #[allow(clippy::type_complexity)]
17610 pub fn indptr_type<T1>(
17611 self,
17612 value: T1,
17613 ) -> SparseMatrixIndexCsxBuilder<(T0, T1)>
17614 where
17615 T1: ::planus::WriteAs<::planus::Offset<self::Int>>,
17616 {
17617 let (v0,) = self.0;
17618 SparseMatrixIndexCsxBuilder((v0, value))
17619 }
17620 }
17621
17622 impl<T0, T1> SparseMatrixIndexCsxBuilder<(T0, T1)> {
17623 /// Setter for the [`indptrBuffer` field](SparseMatrixIndexCsx#structfield.indptr_buffer).
17624 #[inline]
17625 #[allow(clippy::type_complexity)]
17626 pub fn indptr_buffer<T2>(
17627 self,
17628 value: T2,
17629 ) -> SparseMatrixIndexCsxBuilder<(T0, T1, T2)>
17630 where
17631 T2: ::planus::WriteAs<self::Buffer>,
17632 {
17633 let (v0, v1) = self.0;
17634 SparseMatrixIndexCsxBuilder((v0, v1, value))
17635 }
17636 }
17637
17638 impl<T0, T1, T2> SparseMatrixIndexCsxBuilder<(T0, T1, T2)> {
17639 /// Setter for the [`indicesType` field](SparseMatrixIndexCsx#structfield.indices_type).
17640 #[inline]
17641 #[allow(clippy::type_complexity)]
17642 pub fn indices_type<T3>(
17643 self,
17644 value: T3,
17645 ) -> SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3)>
17646 where
17647 T3: ::planus::WriteAs<::planus::Offset<self::Int>>,
17648 {
17649 let (v0, v1, v2) = self.0;
17650 SparseMatrixIndexCsxBuilder((v0, v1, v2, value))
17651 }
17652 }
17653
17654 impl<T0, T1, T2, T3> SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3)> {
17655 /// Setter for the [`indicesBuffer` field](SparseMatrixIndexCsx#structfield.indices_buffer).
17656 #[inline]
17657 #[allow(clippy::type_complexity)]
17658 pub fn indices_buffer<T4>(
17659 self,
17660 value: T4,
17661 ) -> SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3, T4)>
17662 where
17663 T4: ::planus::WriteAs<self::Buffer>,
17664 {
17665 let (v0, v1, v2, v3) = self.0;
17666 SparseMatrixIndexCsxBuilder((v0, v1, v2, v3, value))
17667 }
17668 }
17669
17670 impl<T0, T1, T2, T3, T4> SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3, T4)> {
17671 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SparseMatrixIndexCsx].
17672 #[inline]
17673 pub fn finish(
17674 self,
17675 builder: &mut ::planus::Builder,
17676 ) -> ::planus::Offset<SparseMatrixIndexCsx>
17677 where
17678 Self: ::planus::WriteAsOffset<SparseMatrixIndexCsx>,
17679 {
17680 ::planus::WriteAsOffset::prepare(&self, builder)
17681 }
17682 }
17683
17684 impl<
17685 T0: ::planus::WriteAsDefault<
17686 self::SparseMatrixCompressedAxis,
17687 self::SparseMatrixCompressedAxis,
17688 >,
17689 T1: ::planus::WriteAs<::planus::Offset<self::Int>>,
17690 T2: ::planus::WriteAs<self::Buffer>,
17691 T3: ::planus::WriteAs<::planus::Offset<self::Int>>,
17692 T4: ::planus::WriteAs<self::Buffer>,
17693 >
17694 ::planus::WriteAs<::planus::Offset<SparseMatrixIndexCsx>>
17695 for SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3, T4)>
17696 {
17697 type Prepared = ::planus::Offset<SparseMatrixIndexCsx>;
17698
17699 #[inline]
17700 fn prepare(
17701 &self,
17702 builder: &mut ::planus::Builder,
17703 ) -> ::planus::Offset<SparseMatrixIndexCsx> {
17704 ::planus::WriteAsOffset::prepare(self, builder)
17705 }
17706 }
17707
17708 impl<
17709 T0: ::planus::WriteAsDefault<
17710 self::SparseMatrixCompressedAxis,
17711 self::SparseMatrixCompressedAxis,
17712 >,
17713 T1: ::planus::WriteAs<::planus::Offset<self::Int>>,
17714 T2: ::planus::WriteAs<self::Buffer>,
17715 T3: ::planus::WriteAs<::planus::Offset<self::Int>>,
17716 T4: ::planus::WriteAs<self::Buffer>,
17717 >
17718 ::planus::WriteAsOptional<::planus::Offset<SparseMatrixIndexCsx>>
17719 for SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3, T4)>
17720 {
17721 type Prepared = ::planus::Offset<SparseMatrixIndexCsx>;
17722
17723 #[inline]
17724 fn prepare(
17725 &self,
17726 builder: &mut ::planus::Builder,
17727 ) -> ::core::option::Option<::planus::Offset<SparseMatrixIndexCsx>>
17728 {
17729 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
17730 self, builder,
17731 ))
17732 }
17733 }
17734
17735 impl<
17736 T0: ::planus::WriteAsDefault<
17737 self::SparseMatrixCompressedAxis,
17738 self::SparseMatrixCompressedAxis,
17739 >,
17740 T1: ::planus::WriteAs<::planus::Offset<self::Int>>,
17741 T2: ::planus::WriteAs<self::Buffer>,
17742 T3: ::planus::WriteAs<::planus::Offset<self::Int>>,
17743 T4: ::planus::WriteAs<self::Buffer>,
17744 > ::planus::WriteAsOffset<SparseMatrixIndexCsx>
17745 for SparseMatrixIndexCsxBuilder<(T0, T1, T2, T3, T4)>
17746 {
17747 #[inline]
17748 fn prepare(
17749 &self,
17750 builder: &mut ::planus::Builder,
17751 ) -> ::planus::Offset<SparseMatrixIndexCsx> {
17752 let (v0, v1, v2, v3, v4) = &self.0;
17753 SparseMatrixIndexCsx::create(builder, v0, v1, v2, v3, v4)
17754 }
17755 }
17756
17757 /// Reference to a deserialized [SparseMatrixIndexCsx].
17758 #[derive(Copy, Clone)]
17759 pub struct SparseMatrixIndexCsxRef<'a>(::planus::table_reader::Table<'a>);
17760
17761 impl<'a> SparseMatrixIndexCsxRef<'a> {
17762 /// Getter for the [`compressedAxis` field](SparseMatrixIndexCsx#structfield.compressed_axis).
17763 #[inline]
17764 pub fn compressed_axis(
17765 &self,
17766 ) -> ::planus::Result<self::SparseMatrixCompressedAxis>
17767 {
17768 ::core::result::Result::Ok(
17769 self.0
17770 .access(0, "SparseMatrixIndexCsx", "compressed_axis")?
17771 .unwrap_or(self::SparseMatrixCompressedAxis::Row),
17772 )
17773 }
17774
17775 /// Getter for the [`indptrType` field](SparseMatrixIndexCsx#structfield.indptr_type).
17776 #[inline]
17777 pub fn indptr_type(&self) -> ::planus::Result<self::IntRef<'a>> {
17778 self.0
17779 .access_required(1, "SparseMatrixIndexCsx", "indptr_type")
17780 }
17781
17782 /// Getter for the [`indptrBuffer` field](SparseMatrixIndexCsx#structfield.indptr_buffer).
17783 #[inline]
17784 pub fn indptr_buffer(&self) -> ::planus::Result<self::BufferRef<'a>> {
17785 self.0
17786 .access_required(2, "SparseMatrixIndexCsx", "indptr_buffer")
17787 }
17788
17789 /// Getter for the [`indicesType` field](SparseMatrixIndexCsx#structfield.indices_type).
17790 #[inline]
17791 pub fn indices_type(&self) -> ::planus::Result<self::IntRef<'a>> {
17792 self.0
17793 .access_required(3, "SparseMatrixIndexCsx", "indices_type")
17794 }
17795
17796 /// Getter for the [`indicesBuffer` field](SparseMatrixIndexCsx#structfield.indices_buffer).
17797 #[inline]
17798 pub fn indices_buffer(&self) -> ::planus::Result<self::BufferRef<'a>> {
17799 self.0
17800 .access_required(4, "SparseMatrixIndexCsx", "indices_buffer")
17801 }
17802 }
17803
17804 impl<'a> ::core::fmt::Debug for SparseMatrixIndexCsxRef<'a> {
17805 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
17806 let mut f = f.debug_struct("SparseMatrixIndexCsxRef");
17807 f.field("compressed_axis", &self.compressed_axis());
17808 f.field("indptr_type", &self.indptr_type());
17809 f.field("indptr_buffer", &self.indptr_buffer());
17810 f.field("indices_type", &self.indices_type());
17811 f.field("indices_buffer", &self.indices_buffer());
17812 f.finish()
17813 }
17814 }
17815
17816 impl<'a> ::core::convert::TryFrom<SparseMatrixIndexCsxRef<'a>> for SparseMatrixIndexCsx {
17817 type Error = ::planus::Error;
17818
17819 #[allow(unreachable_code)]
17820 fn try_from(value: SparseMatrixIndexCsxRef<'a>) -> ::planus::Result<Self> {
17821 ::core::result::Result::Ok(Self {
17822 compressed_axis: ::core::convert::TryInto::try_into(
17823 value.compressed_axis()?,
17824 )?,
17825 indptr_type: ::planus::alloc::boxed::Box::new(
17826 ::core::convert::TryInto::try_into(value.indptr_type()?)?,
17827 ),
17828 indptr_buffer: ::core::convert::Into::into(value.indptr_buffer()?),
17829 indices_type: ::planus::alloc::boxed::Box::new(
17830 ::core::convert::TryInto::try_into(value.indices_type()?)?,
17831 ),
17832 indices_buffer: ::core::convert::Into::into(
17833 value.indices_buffer()?,
17834 ),
17835 })
17836 }
17837 }
17838
17839 impl<'a> ::planus::TableRead<'a> for SparseMatrixIndexCsxRef<'a> {
17840 #[inline]
17841 fn from_buffer(
17842 buffer: ::planus::SliceWithStartOffset<'a>,
17843 offset: usize,
17844 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
17845 {
17846 ::core::result::Result::Ok(Self(
17847 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
17848 ))
17849 }
17850 }
17851
17852 impl<'a> ::planus::VectorReadInner<'a> for SparseMatrixIndexCsxRef<'a> {
17853 type Error = ::planus::Error;
17854 const STRIDE: usize = 4;
17855
17856 unsafe fn from_buffer(
17857 buffer: ::planus::SliceWithStartOffset<'a>,
17858 offset: usize,
17859 ) -> ::planus::Result<Self> {
17860 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
17861 error_kind.with_error_location(
17862 "[SparseMatrixIndexCsxRef]",
17863 "get",
17864 buffer.offset_from_start,
17865 )
17866 })
17867 }
17868 }
17869
17870 /// # Safety
17871 /// The planus compiler generates implementations that initialize
17872 /// the bytes in `write_values`.
17873 unsafe impl ::planus::VectorWrite<::planus::Offset<SparseMatrixIndexCsx>> for SparseMatrixIndexCsx {
17874 type Value = ::planus::Offset<SparseMatrixIndexCsx>;
17875 const STRIDE: usize = 4;
17876 #[inline]
17877 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
17878 ::planus::WriteAs::prepare(self, builder)
17879 }
17880
17881 #[inline]
17882 unsafe fn write_values(
17883 values: &[::planus::Offset<SparseMatrixIndexCsx>],
17884 bytes: *mut ::core::mem::MaybeUninit<u8>,
17885 buffer_position: u32,
17886 ) {
17887 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
17888 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
17889 ::planus::WriteAsPrimitive::write(
17890 v,
17891 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
17892 buffer_position - (Self::STRIDE * i) as u32,
17893 );
17894 }
17895 }
17896 }
17897
17898 impl<'a> ::planus::ReadAsRoot<'a> for SparseMatrixIndexCsxRef<'a> {
17899 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
17900 ::planus::TableRead::from_buffer(
17901 ::planus::SliceWithStartOffset {
17902 buffer: slice,
17903 offset_from_start: 0,
17904 },
17905 0,
17906 )
17907 .map_err(|error_kind| {
17908 error_kind.with_error_location(
17909 "[SparseMatrixIndexCsxRef]",
17910 "read_as_root",
17911 0,
17912 )
17913 })
17914 }
17915 }
17916
17917 /// Compressed Sparse Fiber (CSF) sparse tensor index.
17918 ///
17919 /// Generated from these locations:
17920 /// * Table `SparseTensorIndexCSF` in the file `SparseTensor.fbs:128`
17921 #[derive(
17922 Clone,
17923 Debug,
17924 PartialEq,
17925 PartialOrd,
17926 Eq,
17927 Ord,
17928 Hash,
17929 ::serde::Serialize,
17930 ::serde::Deserialize,
17931 )]
17932 pub struct SparseTensorIndexCsf {
17933 /// CSF is a generalization of compressed sparse row (CSR) index.
17934 /// See [smith2017knl](http://shaden.io/pub-files/smith2017knl.pdf)
17935 ///
17936 /// CSF index recursively compresses each dimension of a tensor into a set
17937 /// of prefix trees. Each path from a root to leaf forms one tensor
17938 /// non-zero index. CSF is implemented with two arrays of buffers and one
17939 /// arrays of integers.
17940 ///
17941 /// For example, let X be a 2x3x4x5 tensor and let it have the following
17942 /// 8 non-zero values:
17943 /// ```text
17944 /// X[0, 0, 0, 1] := 1
17945 /// X[0, 0, 0, 2] := 2
17946 /// X[0, 1, 0, 0] := 3
17947 /// X[0, 1, 0, 2] := 4
17948 /// X[0, 1, 1, 0] := 5
17949 /// X[1, 1, 1, 0] := 6
17950 /// X[1, 1, 1, 1] := 7
17951 /// X[1, 1, 1, 2] := 8
17952 /// ```
17953 /// As a prefix tree this would be represented as:
17954 /// ```text
17955 /// 0 1
17956 /// / \ |
17957 /// 0 1 1
17958 /// / / \ |
17959 /// 0 0 1 1
17960 /// /| /| | /| |
17961 /// 1 2 0 2 0 0 1 2
17962 /// ```
17963 /// The type of values in indptrBuffers
17964 pub indptr_type: ::planus::alloc::boxed::Box<self::Int>,
17965 /// indptrBuffers stores the sparsity structure.
17966 /// Each two consecutive dimensions in a tensor correspond to a buffer in
17967 /// indptrBuffers. A pair of consecutive values at `indptrBuffers[dim][i]`
17968 /// and `indptrBuffers[dim][i + 1]` signify a range of nodes in
17969 /// `indicesBuffers[dim + 1]` who are children of `indicesBuffers[dim][i]` node.
17970 ///
17971 /// For example, the indptrBuffers for the above X is:
17972 /// ```text
17973 /// indptrBuffer(X) = [
17974 /// [0, 2, 3],
17975 /// [0, 1, 3, 4],
17976 /// [0, 2, 4, 5, 8]
17977 /// ].
17978 /// ```
17979 pub indptr_buffers: ::planus::alloc::vec::Vec<self::Buffer>,
17980 /// The type of values in indicesBuffers
17981 pub indices_type: ::planus::alloc::boxed::Box<self::Int>,
17982 /// indicesBuffers stores values of nodes.
17983 /// Each tensor dimension corresponds to a buffer in indicesBuffers.
17984 /// For example, the indicesBuffers for the above X is:
17985 /// ```text
17986 /// indicesBuffer(X) = [
17987 /// [0, 1],
17988 /// [0, 1, 1],
17989 /// [0, 0, 1, 1],
17990 /// [1, 2, 0, 2, 0, 0, 1, 2]
17991 /// ].
17992 /// ```
17993 pub indices_buffers: ::planus::alloc::vec::Vec<self::Buffer>,
17994 /// axisOrder stores the sequence in which dimensions were traversed to
17995 /// produce the prefix tree.
17996 /// For example, the axisOrder for the above X is:
17997 /// ```text
17998 /// axisOrder(X) = [0, 1, 2, 3].
17999 /// ```
18000 pub axis_order: ::planus::alloc::vec::Vec<i32>,
18001 }
18002
18003 #[allow(clippy::derivable_impls)]
18004 impl ::core::default::Default for SparseTensorIndexCsf {
18005 fn default() -> Self {
18006 Self {
18007 indptr_type: ::core::default::Default::default(),
18008 indptr_buffers: ::core::default::Default::default(),
18009 indices_type: ::core::default::Default::default(),
18010 indices_buffers: ::core::default::Default::default(),
18011 axis_order: ::core::default::Default::default(),
18012 }
18013 }
18014 }
18015
18016 impl SparseTensorIndexCsf {
18017 /// Creates a [SparseTensorIndexCsfBuilder] for serializing an instance of this table.
18018 #[inline]
18019 pub fn builder() -> SparseTensorIndexCsfBuilder<()> {
18020 SparseTensorIndexCsfBuilder(())
18021 }
18022
18023 #[allow(clippy::too_many_arguments)]
18024 pub fn create(
18025 builder: &mut ::planus::Builder,
18026 field_indptr_type: impl ::planus::WriteAs<::planus::Offset<self::Int>>,
18027 field_indptr_buffers: impl ::planus::WriteAs<
18028 ::planus::Offset<[self::Buffer]>,
18029 >,
18030 field_indices_type: impl ::planus::WriteAs<::planus::Offset<self::Int>>,
18031 field_indices_buffers: impl ::planus::WriteAs<
18032 ::planus::Offset<[self::Buffer]>,
18033 >,
18034 field_axis_order: impl ::planus::WriteAs<::planus::Offset<[i32]>>,
18035 ) -> ::planus::Offset<Self> {
18036 let prepared_indptr_type = field_indptr_type.prepare(builder);
18037 let prepared_indptr_buffers = field_indptr_buffers.prepare(builder);
18038 let prepared_indices_type = field_indices_type.prepare(builder);
18039 let prepared_indices_buffers = field_indices_buffers.prepare(builder);
18040 let prepared_axis_order = field_axis_order.prepare(builder);
18041
18042 let mut table_writer: ::planus::table_writer::TableWriter<14> =
18043 ::core::default::Default::default();
18044 table_writer.write_entry::<::planus::Offset<self::Int>>(0);
18045 table_writer.write_entry::<::planus::Offset<[self::Buffer]>>(1);
18046 table_writer.write_entry::<::planus::Offset<self::Int>>(2);
18047 table_writer.write_entry::<::planus::Offset<[self::Buffer]>>(3);
18048 table_writer.write_entry::<::planus::Offset<[i32]>>(4);
18049
18050 unsafe {
18051 table_writer.finish(builder, |object_writer| {
18052 object_writer.write::<_, _, 4>(&prepared_indptr_type);
18053 object_writer.write::<_, _, 4>(&prepared_indptr_buffers);
18054 object_writer.write::<_, _, 4>(&prepared_indices_type);
18055 object_writer.write::<_, _, 4>(&prepared_indices_buffers);
18056 object_writer.write::<_, _, 4>(&prepared_axis_order);
18057 });
18058 }
18059 builder.current_offset()
18060 }
18061 }
18062
18063 impl ::planus::WriteAs<::planus::Offset<SparseTensorIndexCsf>> for SparseTensorIndexCsf {
18064 type Prepared = ::planus::Offset<Self>;
18065
18066 #[inline]
18067 fn prepare(
18068 &self,
18069 builder: &mut ::planus::Builder,
18070 ) -> ::planus::Offset<SparseTensorIndexCsf> {
18071 ::planus::WriteAsOffset::prepare(self, builder)
18072 }
18073 }
18074
18075 impl ::planus::WriteAsOptional<::planus::Offset<SparseTensorIndexCsf>> for SparseTensorIndexCsf {
18076 type Prepared = ::planus::Offset<Self>;
18077
18078 #[inline]
18079 fn prepare(
18080 &self,
18081 builder: &mut ::planus::Builder,
18082 ) -> ::core::option::Option<::planus::Offset<SparseTensorIndexCsf>>
18083 {
18084 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
18085 self, builder,
18086 ))
18087 }
18088 }
18089
18090 impl ::planus::WriteAsOffset<SparseTensorIndexCsf> for SparseTensorIndexCsf {
18091 #[inline]
18092 fn prepare(
18093 &self,
18094 builder: &mut ::planus::Builder,
18095 ) -> ::planus::Offset<SparseTensorIndexCsf> {
18096 SparseTensorIndexCsf::create(
18097 builder,
18098 &self.indptr_type,
18099 &self.indptr_buffers,
18100 &self.indices_type,
18101 &self.indices_buffers,
18102 &self.axis_order,
18103 )
18104 }
18105 }
18106
18107 /// Builder for serializing an instance of the [SparseTensorIndexCsf] type.
18108 ///
18109 /// Can be created using the [SparseTensorIndexCsf::builder] method.
18110 #[derive(Debug)]
18111 #[must_use]
18112 pub struct SparseTensorIndexCsfBuilder<State>(State);
18113
18114 impl SparseTensorIndexCsfBuilder<()> {
18115 /// Setter for the [`indptrType` field](SparseTensorIndexCsf#structfield.indptr_type).
18116 #[inline]
18117 #[allow(clippy::type_complexity)]
18118 pub fn indptr_type<T0>(
18119 self,
18120 value: T0,
18121 ) -> SparseTensorIndexCsfBuilder<(T0,)>
18122 where
18123 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
18124 {
18125 SparseTensorIndexCsfBuilder((value,))
18126 }
18127 }
18128
18129 impl<T0> SparseTensorIndexCsfBuilder<(T0,)> {
18130 /// Setter for the [`indptrBuffers` field](SparseTensorIndexCsf#structfield.indptr_buffers).
18131 #[inline]
18132 #[allow(clippy::type_complexity)]
18133 pub fn indptr_buffers<T1>(
18134 self,
18135 value: T1,
18136 ) -> SparseTensorIndexCsfBuilder<(T0, T1)>
18137 where
18138 T1: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18139 {
18140 let (v0,) = self.0;
18141 SparseTensorIndexCsfBuilder((v0, value))
18142 }
18143 }
18144
18145 impl<T0, T1> SparseTensorIndexCsfBuilder<(T0, T1)> {
18146 /// Setter for the [`indicesType` field](SparseTensorIndexCsf#structfield.indices_type).
18147 #[inline]
18148 #[allow(clippy::type_complexity)]
18149 pub fn indices_type<T2>(
18150 self,
18151 value: T2,
18152 ) -> SparseTensorIndexCsfBuilder<(T0, T1, T2)>
18153 where
18154 T2: ::planus::WriteAs<::planus::Offset<self::Int>>,
18155 {
18156 let (v0, v1) = self.0;
18157 SparseTensorIndexCsfBuilder((v0, v1, value))
18158 }
18159 }
18160
18161 impl<T0, T1, T2> SparseTensorIndexCsfBuilder<(T0, T1, T2)> {
18162 /// Setter for the [`indicesBuffers` field](SparseTensorIndexCsf#structfield.indices_buffers).
18163 #[inline]
18164 #[allow(clippy::type_complexity)]
18165 pub fn indices_buffers<T3>(
18166 self,
18167 value: T3,
18168 ) -> SparseTensorIndexCsfBuilder<(T0, T1, T2, T3)>
18169 where
18170 T3: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18171 {
18172 let (v0, v1, v2) = self.0;
18173 SparseTensorIndexCsfBuilder((v0, v1, v2, value))
18174 }
18175 }
18176
18177 impl<T0, T1, T2, T3> SparseTensorIndexCsfBuilder<(T0, T1, T2, T3)> {
18178 /// Setter for the [`axisOrder` field](SparseTensorIndexCsf#structfield.axis_order).
18179 #[inline]
18180 #[allow(clippy::type_complexity)]
18181 pub fn axis_order<T4>(
18182 self,
18183 value: T4,
18184 ) -> SparseTensorIndexCsfBuilder<(T0, T1, T2, T3, T4)>
18185 where
18186 T4: ::planus::WriteAs<::planus::Offset<[i32]>>,
18187 {
18188 let (v0, v1, v2, v3) = self.0;
18189 SparseTensorIndexCsfBuilder((v0, v1, v2, v3, value))
18190 }
18191 }
18192
18193 impl<T0, T1, T2, T3, T4> SparseTensorIndexCsfBuilder<(T0, T1, T2, T3, T4)> {
18194 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SparseTensorIndexCsf].
18195 #[inline]
18196 pub fn finish(
18197 self,
18198 builder: &mut ::planus::Builder,
18199 ) -> ::planus::Offset<SparseTensorIndexCsf>
18200 where
18201 Self: ::planus::WriteAsOffset<SparseTensorIndexCsf>,
18202 {
18203 ::planus::WriteAsOffset::prepare(&self, builder)
18204 }
18205 }
18206
18207 impl<
18208 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
18209 T1: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18210 T2: ::planus::WriteAs<::planus::Offset<self::Int>>,
18211 T3: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18212 T4: ::planus::WriteAs<::planus::Offset<[i32]>>,
18213 >
18214 ::planus::WriteAs<::planus::Offset<SparseTensorIndexCsf>>
18215 for SparseTensorIndexCsfBuilder<(T0, T1, T2, T3, T4)>
18216 {
18217 type Prepared = ::planus::Offset<SparseTensorIndexCsf>;
18218
18219 #[inline]
18220 fn prepare(
18221 &self,
18222 builder: &mut ::planus::Builder,
18223 ) -> ::planus::Offset<SparseTensorIndexCsf> {
18224 ::planus::WriteAsOffset::prepare(self, builder)
18225 }
18226 }
18227
18228 impl<
18229 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
18230 T1: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18231 T2: ::planus::WriteAs<::planus::Offset<self::Int>>,
18232 T3: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18233 T4: ::planus::WriteAs<::planus::Offset<[i32]>>,
18234 >
18235 ::planus::WriteAsOptional<::planus::Offset<SparseTensorIndexCsf>>
18236 for SparseTensorIndexCsfBuilder<(T0, T1, T2, T3, T4)>
18237 {
18238 type Prepared = ::planus::Offset<SparseTensorIndexCsf>;
18239
18240 #[inline]
18241 fn prepare(
18242 &self,
18243 builder: &mut ::planus::Builder,
18244 ) -> ::core::option::Option<::planus::Offset<SparseTensorIndexCsf>>
18245 {
18246 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
18247 self, builder,
18248 ))
18249 }
18250 }
18251
18252 impl<
18253 T0: ::planus::WriteAs<::planus::Offset<self::Int>>,
18254 T1: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18255 T2: ::planus::WriteAs<::planus::Offset<self::Int>>,
18256 T3: ::planus::WriteAs<::planus::Offset<[self::Buffer]>>,
18257 T4: ::planus::WriteAs<::planus::Offset<[i32]>>,
18258 > ::planus::WriteAsOffset<SparseTensorIndexCsf>
18259 for SparseTensorIndexCsfBuilder<(T0, T1, T2, T3, T4)>
18260 {
18261 #[inline]
18262 fn prepare(
18263 &self,
18264 builder: &mut ::planus::Builder,
18265 ) -> ::planus::Offset<SparseTensorIndexCsf> {
18266 let (v0, v1, v2, v3, v4) = &self.0;
18267 SparseTensorIndexCsf::create(builder, v0, v1, v2, v3, v4)
18268 }
18269 }
18270
18271 /// Reference to a deserialized [SparseTensorIndexCsf].
18272 #[derive(Copy, Clone)]
18273 pub struct SparseTensorIndexCsfRef<'a>(::planus::table_reader::Table<'a>);
18274
18275 impl<'a> SparseTensorIndexCsfRef<'a> {
18276 /// Getter for the [`indptrType` field](SparseTensorIndexCsf#structfield.indptr_type).
18277 #[inline]
18278 pub fn indptr_type(&self) -> ::planus::Result<self::IntRef<'a>> {
18279 self.0
18280 .access_required(0, "SparseTensorIndexCsf", "indptr_type")
18281 }
18282
18283 /// Getter for the [`indptrBuffers` field](SparseTensorIndexCsf#structfield.indptr_buffers).
18284 #[inline]
18285 pub fn indptr_buffers(
18286 &self,
18287 ) -> ::planus::Result<::planus::Vector<'a, self::BufferRef<'a>>>
18288 {
18289 self.0
18290 .access_required(1, "SparseTensorIndexCsf", "indptr_buffers")
18291 }
18292
18293 /// Getter for the [`indicesType` field](SparseTensorIndexCsf#structfield.indices_type).
18294 #[inline]
18295 pub fn indices_type(&self) -> ::planus::Result<self::IntRef<'a>> {
18296 self.0
18297 .access_required(2, "SparseTensorIndexCsf", "indices_type")
18298 }
18299
18300 /// Getter for the [`indicesBuffers` field](SparseTensorIndexCsf#structfield.indices_buffers).
18301 #[inline]
18302 pub fn indices_buffers(
18303 &self,
18304 ) -> ::planus::Result<::planus::Vector<'a, self::BufferRef<'a>>>
18305 {
18306 self.0
18307 .access_required(3, "SparseTensorIndexCsf", "indices_buffers")
18308 }
18309
18310 /// Getter for the [`axisOrder` field](SparseTensorIndexCsf#structfield.axis_order).
18311 #[inline]
18312 pub fn axis_order(&self) -> ::planus::Result<::planus::Vector<'a, i32>> {
18313 self.0
18314 .access_required(4, "SparseTensorIndexCsf", "axis_order")
18315 }
18316 }
18317
18318 impl<'a> ::core::fmt::Debug for SparseTensorIndexCsfRef<'a> {
18319 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
18320 let mut f = f.debug_struct("SparseTensorIndexCsfRef");
18321 f.field("indptr_type", &self.indptr_type());
18322 f.field("indptr_buffers", &self.indptr_buffers());
18323 f.field("indices_type", &self.indices_type());
18324 f.field("indices_buffers", &self.indices_buffers());
18325 f.field("axis_order", &self.axis_order());
18326 f.finish()
18327 }
18328 }
18329
18330 impl<'a> ::core::convert::TryFrom<SparseTensorIndexCsfRef<'a>> for SparseTensorIndexCsf {
18331 type Error = ::planus::Error;
18332
18333 #[allow(unreachable_code)]
18334 fn try_from(value: SparseTensorIndexCsfRef<'a>) -> ::planus::Result<Self> {
18335 ::core::result::Result::Ok(Self {
18336 indptr_type: ::planus::alloc::boxed::Box::new(
18337 ::core::convert::TryInto::try_into(value.indptr_type()?)?,
18338 ),
18339 indptr_buffers: value.indptr_buffers()?.to_vec()?,
18340 indices_type: ::planus::alloc::boxed::Box::new(
18341 ::core::convert::TryInto::try_into(value.indices_type()?)?,
18342 ),
18343 indices_buffers: value.indices_buffers()?.to_vec()?,
18344 axis_order: value.axis_order()?.to_vec()?,
18345 })
18346 }
18347 }
18348
18349 impl<'a> ::planus::TableRead<'a> for SparseTensorIndexCsfRef<'a> {
18350 #[inline]
18351 fn from_buffer(
18352 buffer: ::planus::SliceWithStartOffset<'a>,
18353 offset: usize,
18354 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
18355 {
18356 ::core::result::Result::Ok(Self(
18357 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
18358 ))
18359 }
18360 }
18361
18362 impl<'a> ::planus::VectorReadInner<'a> for SparseTensorIndexCsfRef<'a> {
18363 type Error = ::planus::Error;
18364 const STRIDE: usize = 4;
18365
18366 unsafe fn from_buffer(
18367 buffer: ::planus::SliceWithStartOffset<'a>,
18368 offset: usize,
18369 ) -> ::planus::Result<Self> {
18370 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
18371 error_kind.with_error_location(
18372 "[SparseTensorIndexCsfRef]",
18373 "get",
18374 buffer.offset_from_start,
18375 )
18376 })
18377 }
18378 }
18379
18380 /// # Safety
18381 /// The planus compiler generates implementations that initialize
18382 /// the bytes in `write_values`.
18383 unsafe impl ::planus::VectorWrite<::planus::Offset<SparseTensorIndexCsf>> for SparseTensorIndexCsf {
18384 type Value = ::planus::Offset<SparseTensorIndexCsf>;
18385 const STRIDE: usize = 4;
18386 #[inline]
18387 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
18388 ::planus::WriteAs::prepare(self, builder)
18389 }
18390
18391 #[inline]
18392 unsafe fn write_values(
18393 values: &[::planus::Offset<SparseTensorIndexCsf>],
18394 bytes: *mut ::core::mem::MaybeUninit<u8>,
18395 buffer_position: u32,
18396 ) {
18397 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
18398 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
18399 ::planus::WriteAsPrimitive::write(
18400 v,
18401 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
18402 buffer_position - (Self::STRIDE * i) as u32,
18403 );
18404 }
18405 }
18406 }
18407
18408 impl<'a> ::planus::ReadAsRoot<'a> for SparseTensorIndexCsfRef<'a> {
18409 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
18410 ::planus::TableRead::from_buffer(
18411 ::planus::SliceWithStartOffset {
18412 buffer: slice,
18413 offset_from_start: 0,
18414 },
18415 0,
18416 )
18417 .map_err(|error_kind| {
18418 error_kind.with_error_location(
18419 "[SparseTensorIndexCsfRef]",
18420 "read_as_root",
18421 0,
18422 )
18423 })
18424 }
18425 }
18426
18427 /// The union `SparseTensorIndex` in the namespace `org.apache.arrow.flatbuf`
18428 ///
18429 /// Generated from these locations:
18430 /// * Union `SparseTensorIndex` in the file `SparseTensor.fbs:203`
18431 #[derive(
18432 Clone,
18433 Debug,
18434 PartialEq,
18435 PartialOrd,
18436 Eq,
18437 Ord,
18438 Hash,
18439 ::serde::Serialize,
18440 ::serde::Deserialize,
18441 )]
18442 pub enum SparseTensorIndex {
18443 /// The variant of type `SparseTensorIndexCOO` in the union `SparseTensorIndex`
18444 SparseTensorIndexCoo(
18445 ::planus::alloc::boxed::Box<self::SparseTensorIndexCoo>,
18446 ),
18447
18448 /// The variant of type `SparseMatrixIndexCSX` in the union `SparseTensorIndex`
18449 SparseMatrixIndexCsx(
18450 ::planus::alloc::boxed::Box<self::SparseMatrixIndexCsx>,
18451 ),
18452
18453 /// The variant of type `SparseTensorIndexCSF` in the union `SparseTensorIndex`
18454 SparseTensorIndexCsf(
18455 ::planus::alloc::boxed::Box<self::SparseTensorIndexCsf>,
18456 ),
18457 }
18458
18459 impl SparseTensorIndex {
18460 /// Creates a [SparseTensorIndexBuilder] for serializing an instance of this table.
18461 #[inline]
18462 pub fn builder() -> SparseTensorIndexBuilder<::planus::Uninitialized> {
18463 SparseTensorIndexBuilder(::planus::Uninitialized)
18464 }
18465
18466 #[inline]
18467 pub fn create_sparse_tensor_index_coo(
18468 builder: &mut ::planus::Builder,
18469 value: impl ::planus::WriteAsOffset<self::SparseTensorIndexCoo>,
18470 ) -> ::planus::UnionOffset<Self> {
18471 ::planus::UnionOffset::new(1, value.prepare(builder).downcast())
18472 }
18473
18474 #[inline]
18475 pub fn create_sparse_matrix_index_csx(
18476 builder: &mut ::planus::Builder,
18477 value: impl ::planus::WriteAsOffset<self::SparseMatrixIndexCsx>,
18478 ) -> ::planus::UnionOffset<Self> {
18479 ::planus::UnionOffset::new(2, value.prepare(builder).downcast())
18480 }
18481
18482 #[inline]
18483 pub fn create_sparse_tensor_index_csf(
18484 builder: &mut ::planus::Builder,
18485 value: impl ::planus::WriteAsOffset<self::SparseTensorIndexCsf>,
18486 ) -> ::planus::UnionOffset<Self> {
18487 ::planus::UnionOffset::new(3, value.prepare(builder).downcast())
18488 }
18489 }
18490
18491 impl ::planus::WriteAsUnion<SparseTensorIndex> for SparseTensorIndex {
18492 #[inline]
18493 fn prepare(
18494 &self,
18495 builder: &mut ::planus::Builder,
18496 ) -> ::planus::UnionOffset<Self> {
18497 match self {
18498 Self::SparseTensorIndexCoo(value) => {
18499 Self::create_sparse_tensor_index_coo(builder, value)
18500 }
18501 Self::SparseMatrixIndexCsx(value) => {
18502 Self::create_sparse_matrix_index_csx(builder, value)
18503 }
18504 Self::SparseTensorIndexCsf(value) => {
18505 Self::create_sparse_tensor_index_csf(builder, value)
18506 }
18507 }
18508 }
18509 }
18510
18511 impl ::planus::WriteAsOptionalUnion<SparseTensorIndex> for SparseTensorIndex {
18512 #[inline]
18513 fn prepare(
18514 &self,
18515 builder: &mut ::planus::Builder,
18516 ) -> ::core::option::Option<::planus::UnionOffset<Self>>
18517 {
18518 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
18519 self, builder,
18520 ))
18521 }
18522 }
18523
18524 /// Builder for serializing an instance of the [SparseTensorIndex] type.
18525 ///
18526 /// Can be created using the [SparseTensorIndex::builder] method.
18527 #[derive(Debug)]
18528 #[must_use]
18529 pub struct SparseTensorIndexBuilder<T>(T);
18530
18531 impl SparseTensorIndexBuilder<::planus::Uninitialized> {
18532 /// Creates an instance of the [`SparseTensorIndexCOO` variant](SparseTensorIndex#variant.SparseTensorIndexCoo).
18533 #[inline]
18534 pub fn sparse_tensor_index_coo<T>(
18535 self,
18536 value: T,
18537 ) -> SparseTensorIndexBuilder<::planus::Initialized<1, T>>
18538 where
18539 T: ::planus::WriteAsOffset<self::SparseTensorIndexCoo>,
18540 {
18541 SparseTensorIndexBuilder(::planus::Initialized(value))
18542 }
18543
18544 /// Creates an instance of the [`SparseMatrixIndexCSX` variant](SparseTensorIndex#variant.SparseMatrixIndexCsx).
18545 #[inline]
18546 pub fn sparse_matrix_index_csx<T>(
18547 self,
18548 value: T,
18549 ) -> SparseTensorIndexBuilder<::planus::Initialized<2, T>>
18550 where
18551 T: ::planus::WriteAsOffset<self::SparseMatrixIndexCsx>,
18552 {
18553 SparseTensorIndexBuilder(::planus::Initialized(value))
18554 }
18555
18556 /// Creates an instance of the [`SparseTensorIndexCSF` variant](SparseTensorIndex#variant.SparseTensorIndexCsf).
18557 #[inline]
18558 pub fn sparse_tensor_index_csf<T>(
18559 self,
18560 value: T,
18561 ) -> SparseTensorIndexBuilder<::planus::Initialized<3, T>>
18562 where
18563 T: ::planus::WriteAsOffset<self::SparseTensorIndexCsf>,
18564 {
18565 SparseTensorIndexBuilder(::planus::Initialized(value))
18566 }
18567 }
18568
18569 impl<const N: u8, T> SparseTensorIndexBuilder<::planus::Initialized<N, T>> {
18570 /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [SparseTensorIndex].
18571 #[inline]
18572 pub fn finish(
18573 self,
18574 builder: &mut ::planus::Builder,
18575 ) -> ::planus::UnionOffset<SparseTensorIndex>
18576 where
18577 Self: ::planus::WriteAsUnion<SparseTensorIndex>,
18578 {
18579 ::planus::WriteAsUnion::prepare(&self, builder)
18580 }
18581 }
18582
18583 impl<T> ::planus::WriteAsUnion<SparseTensorIndex>
18584 for SparseTensorIndexBuilder<::planus::Initialized<1, T>>
18585 where
18586 T: ::planus::WriteAsOffset<self::SparseTensorIndexCoo>,
18587 {
18588 #[inline]
18589 fn prepare(
18590 &self,
18591 builder: &mut ::planus::Builder,
18592 ) -> ::planus::UnionOffset<SparseTensorIndex> {
18593 ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast())
18594 }
18595 }
18596
18597 impl<T> ::planus::WriteAsOptionalUnion<SparseTensorIndex>
18598 for SparseTensorIndexBuilder<::planus::Initialized<1, T>>
18599 where
18600 T: ::planus::WriteAsOffset<self::SparseTensorIndexCoo>,
18601 {
18602 #[inline]
18603 fn prepare(
18604 &self,
18605 builder: &mut ::planus::Builder,
18606 ) -> ::core::option::Option<::planus::UnionOffset<SparseTensorIndex>>
18607 {
18608 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
18609 self, builder,
18610 ))
18611 }
18612 }
18613 impl<T> ::planus::WriteAsUnion<SparseTensorIndex>
18614 for SparseTensorIndexBuilder<::planus::Initialized<2, T>>
18615 where
18616 T: ::planus::WriteAsOffset<self::SparseMatrixIndexCsx>,
18617 {
18618 #[inline]
18619 fn prepare(
18620 &self,
18621 builder: &mut ::planus::Builder,
18622 ) -> ::planus::UnionOffset<SparseTensorIndex> {
18623 ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast())
18624 }
18625 }
18626
18627 impl<T> ::planus::WriteAsOptionalUnion<SparseTensorIndex>
18628 for SparseTensorIndexBuilder<::planus::Initialized<2, T>>
18629 where
18630 T: ::planus::WriteAsOffset<self::SparseMatrixIndexCsx>,
18631 {
18632 #[inline]
18633 fn prepare(
18634 &self,
18635 builder: &mut ::planus::Builder,
18636 ) -> ::core::option::Option<::planus::UnionOffset<SparseTensorIndex>>
18637 {
18638 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
18639 self, builder,
18640 ))
18641 }
18642 }
18643 impl<T> ::planus::WriteAsUnion<SparseTensorIndex>
18644 for SparseTensorIndexBuilder<::planus::Initialized<3, T>>
18645 where
18646 T: ::planus::WriteAsOffset<self::SparseTensorIndexCsf>,
18647 {
18648 #[inline]
18649 fn prepare(
18650 &self,
18651 builder: &mut ::planus::Builder,
18652 ) -> ::planus::UnionOffset<SparseTensorIndex> {
18653 ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast())
18654 }
18655 }
18656
18657 impl<T> ::planus::WriteAsOptionalUnion<SparseTensorIndex>
18658 for SparseTensorIndexBuilder<::planus::Initialized<3, T>>
18659 where
18660 T: ::planus::WriteAsOffset<self::SparseTensorIndexCsf>,
18661 {
18662 #[inline]
18663 fn prepare(
18664 &self,
18665 builder: &mut ::planus::Builder,
18666 ) -> ::core::option::Option<::planus::UnionOffset<SparseTensorIndex>>
18667 {
18668 ::core::option::Option::Some(::planus::WriteAsUnion::prepare(
18669 self, builder,
18670 ))
18671 }
18672 }
18673
18674 /// Reference to a deserialized [SparseTensorIndex].
18675 #[derive(Copy, Clone, Debug)]
18676 pub enum SparseTensorIndexRef<'a> {
18677 SparseTensorIndexCoo(self::SparseTensorIndexCooRef<'a>),
18678 SparseMatrixIndexCsx(self::SparseMatrixIndexCsxRef<'a>),
18679 SparseTensorIndexCsf(self::SparseTensorIndexCsfRef<'a>),
18680 }
18681
18682 impl<'a> ::core::convert::TryFrom<SparseTensorIndexRef<'a>> for SparseTensorIndex {
18683 type Error = ::planus::Error;
18684
18685 fn try_from(value: SparseTensorIndexRef<'a>) -> ::planus::Result<Self> {
18686 ::core::result::Result::Ok(match value {
18687 SparseTensorIndexRef::SparseTensorIndexCoo(value) => {
18688 Self::SparseTensorIndexCoo(::planus::alloc::boxed::Box::new(
18689 ::core::convert::TryFrom::try_from(value)?,
18690 ))
18691 }
18692
18693 SparseTensorIndexRef::SparseMatrixIndexCsx(value) => {
18694 Self::SparseMatrixIndexCsx(::planus::alloc::boxed::Box::new(
18695 ::core::convert::TryFrom::try_from(value)?,
18696 ))
18697 }
18698
18699 SparseTensorIndexRef::SparseTensorIndexCsf(value) => {
18700 Self::SparseTensorIndexCsf(::planus::alloc::boxed::Box::new(
18701 ::core::convert::TryFrom::try_from(value)?,
18702 ))
18703 }
18704 })
18705 }
18706 }
18707
18708 impl<'a> ::planus::TableReadUnion<'a> for SparseTensorIndexRef<'a> {
18709 fn from_buffer(
18710 buffer: ::planus::SliceWithStartOffset<'a>,
18711 tag: u8,
18712 field_offset: usize,
18713 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
18714 {
18715 match tag {
18716 1 => ::core::result::Result::Ok(Self::SparseTensorIndexCoo(
18717 ::planus::TableRead::from_buffer(buffer, field_offset)?,
18718 )),
18719 2 => ::core::result::Result::Ok(Self::SparseMatrixIndexCsx(
18720 ::planus::TableRead::from_buffer(buffer, field_offset)?,
18721 )),
18722 3 => ::core::result::Result::Ok(Self::SparseTensorIndexCsf(
18723 ::planus::TableRead::from_buffer(buffer, field_offset)?,
18724 )),
18725 _ => ::core::result::Result::Err(
18726 ::planus::errors::ErrorKind::UnknownUnionTag { tag },
18727 ),
18728 }
18729 }
18730 }
18731
18732 impl<'a> ::planus::VectorReadUnion<'a> for SparseTensorIndexRef<'a> {
18733 const VECTOR_NAME: &'static str = "[SparseTensorIndexRef]";
18734 }
18735
18736 /// The table `SparseTensor` in the namespace `org.apache.arrow.flatbuf`
18737 ///
18738 /// Generated from these locations:
18739 /// * Table `SparseTensor` in the file `SparseTensor.fbs:209`
18740 #[derive(
18741 Clone,
18742 Debug,
18743 PartialEq,
18744 PartialOrd,
18745 Eq,
18746 Ord,
18747 Hash,
18748 ::serde::Serialize,
18749 ::serde::Deserialize,
18750 )]
18751 pub struct SparseTensor {
18752 /// The type of data contained in a value cell.
18753 /// Currently only fixed-width value types are supported,
18754 /// no strings or nested types.
18755 pub type_: self::Type,
18756 /// The dimensions of the tensor, optionally named.
18757 pub shape: ::planus::alloc::vec::Vec<self::TensorDim>,
18758 /// The number of non-zero values in a sparse tensor.
18759 pub non_zero_length: i64,
18760 /// Sparse tensor index
18761 pub sparse_index: self::SparseTensorIndex,
18762 /// The location and size of the tensor's data
18763 pub data: self::Buffer,
18764 }
18765
18766 impl SparseTensor {
18767 /// Creates a [SparseTensorBuilder] for serializing an instance of this table.
18768 #[inline]
18769 pub fn builder() -> SparseTensorBuilder<()> {
18770 SparseTensorBuilder(())
18771 }
18772
18773 #[allow(clippy::too_many_arguments)]
18774 pub fn create(
18775 builder: &mut ::planus::Builder,
18776 field_type_: impl ::planus::WriteAsUnion<self::Type>,
18777 field_shape: impl ::planus::WriteAs<
18778 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
18779 >,
18780 field_non_zero_length: impl ::planus::WriteAsDefault<i64, i64>,
18781 field_sparse_index: impl ::planus::WriteAsUnion<self::SparseTensorIndex>,
18782 field_data: impl ::planus::WriteAs<self::Buffer>,
18783 ) -> ::planus::Offset<Self> {
18784 let prepared_type_ = field_type_.prepare(builder);
18785 let prepared_shape = field_shape.prepare(builder);
18786 let prepared_non_zero_length =
18787 field_non_zero_length.prepare(builder, &0);
18788 let prepared_sparse_index = field_sparse_index.prepare(builder);
18789 let prepared_data = field_data.prepare(builder);
18790
18791 let mut table_writer: ::planus::table_writer::TableWriter<18> =
18792 ::core::default::Default::default();
18793 if prepared_non_zero_length.is_some() {
18794 table_writer.write_entry::<i64>(3);
18795 }
18796 table_writer.write_entry::<self::Buffer>(6);
18797 table_writer.write_entry::<::planus::Offset<self::Type>>(1);
18798 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::TensorDim>]>>(2);
18799 table_writer
18800 .write_entry::<::planus::Offset<self::SparseTensorIndex>>(5);
18801 table_writer.write_entry::<u8>(0);
18802 table_writer.write_entry::<u8>(4);
18803
18804 unsafe {
18805 table_writer.finish(builder, |object_writer| {
18806 if let ::core::option::Option::Some(prepared_non_zero_length) =
18807 prepared_non_zero_length
18808 {
18809 object_writer.write::<_, _, 8>(&prepared_non_zero_length);
18810 }
18811 object_writer.write::<_, _, 16>(&prepared_data);
18812 object_writer.write::<_, _, 4>(&prepared_type_.offset());
18813 object_writer.write::<_, _, 4>(&prepared_shape);
18814 object_writer.write::<_, _, 4>(&prepared_sparse_index.offset());
18815 object_writer.write::<_, _, 1>(&prepared_type_.tag());
18816 object_writer.write::<_, _, 1>(&prepared_sparse_index.tag());
18817 });
18818 }
18819 builder.current_offset()
18820 }
18821 }
18822
18823 impl ::planus::WriteAs<::planus::Offset<SparseTensor>> for SparseTensor {
18824 type Prepared = ::planus::Offset<Self>;
18825
18826 #[inline]
18827 fn prepare(
18828 &self,
18829 builder: &mut ::planus::Builder,
18830 ) -> ::planus::Offset<SparseTensor> {
18831 ::planus::WriteAsOffset::prepare(self, builder)
18832 }
18833 }
18834
18835 impl ::planus::WriteAsOptional<::planus::Offset<SparseTensor>> for SparseTensor {
18836 type Prepared = ::planus::Offset<Self>;
18837
18838 #[inline]
18839 fn prepare(
18840 &self,
18841 builder: &mut ::planus::Builder,
18842 ) -> ::core::option::Option<::planus::Offset<SparseTensor>>
18843 {
18844 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
18845 self, builder,
18846 ))
18847 }
18848 }
18849
18850 impl ::planus::WriteAsOffset<SparseTensor> for SparseTensor {
18851 #[inline]
18852 fn prepare(
18853 &self,
18854 builder: &mut ::planus::Builder,
18855 ) -> ::planus::Offset<SparseTensor> {
18856 SparseTensor::create(
18857 builder,
18858 &self.type_,
18859 &self.shape,
18860 self.non_zero_length,
18861 &self.sparse_index,
18862 self.data,
18863 )
18864 }
18865 }
18866
18867 /// Builder for serializing an instance of the [SparseTensor] type.
18868 ///
18869 /// Can be created using the [SparseTensor::builder] method.
18870 #[derive(Debug)]
18871 #[must_use]
18872 pub struct SparseTensorBuilder<State>(State);
18873
18874 impl SparseTensorBuilder<()> {
18875 /// Setter for the [`type` field](SparseTensor#structfield.type_).
18876 #[inline]
18877 #[allow(clippy::type_complexity)]
18878 pub fn type_<T0>(self, value: T0) -> SparseTensorBuilder<(T0,)>
18879 where
18880 T0: ::planus::WriteAsUnion<self::Type>,
18881 {
18882 SparseTensorBuilder((value,))
18883 }
18884 }
18885
18886 impl<T0> SparseTensorBuilder<(T0,)> {
18887 /// Setter for the [`shape` field](SparseTensor#structfield.shape).
18888 #[inline]
18889 #[allow(clippy::type_complexity)]
18890 pub fn shape<T1>(self, value: T1) -> SparseTensorBuilder<(T0, T1)>
18891 where
18892 T1: ::planus::WriteAs<
18893 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
18894 >,
18895 {
18896 let (v0,) = self.0;
18897 SparseTensorBuilder((v0, value))
18898 }
18899 }
18900
18901 impl<T0, T1> SparseTensorBuilder<(T0, T1)> {
18902 /// Setter for the [`non_zero_length` field](SparseTensor#structfield.non_zero_length).
18903 #[inline]
18904 #[allow(clippy::type_complexity)]
18905 pub fn non_zero_length<T2>(
18906 self,
18907 value: T2,
18908 ) -> SparseTensorBuilder<(T0, T1, T2)>
18909 where
18910 T2: ::planus::WriteAsDefault<i64, i64>,
18911 {
18912 let (v0, v1) = self.0;
18913 SparseTensorBuilder((v0, v1, value))
18914 }
18915
18916 /// Sets the [`non_zero_length` field](SparseTensor#structfield.non_zero_length) to the default value.
18917 #[inline]
18918 #[allow(clippy::type_complexity)]
18919 pub fn non_zero_length_as_default(
18920 self,
18921 ) -> SparseTensorBuilder<(T0, T1, ::planus::DefaultValue)>
18922 {
18923 self.non_zero_length(::planus::DefaultValue)
18924 }
18925 }
18926
18927 impl<T0, T1, T2> SparseTensorBuilder<(T0, T1, T2)> {
18928 /// Setter for the [`sparseIndex` field](SparseTensor#structfield.sparse_index).
18929 #[inline]
18930 #[allow(clippy::type_complexity)]
18931 pub fn sparse_index<T3>(
18932 self,
18933 value: T3,
18934 ) -> SparseTensorBuilder<(T0, T1, T2, T3)>
18935 where
18936 T3: ::planus::WriteAsUnion<self::SparseTensorIndex>,
18937 {
18938 let (v0, v1, v2) = self.0;
18939 SparseTensorBuilder((v0, v1, v2, value))
18940 }
18941 }
18942
18943 impl<T0, T1, T2, T3> SparseTensorBuilder<(T0, T1, T2, T3)> {
18944 /// Setter for the [`data` field](SparseTensor#structfield.data).
18945 #[inline]
18946 #[allow(clippy::type_complexity)]
18947 pub fn data<T4>(
18948 self,
18949 value: T4,
18950 ) -> SparseTensorBuilder<(T0, T1, T2, T3, T4)>
18951 where
18952 T4: ::planus::WriteAs<self::Buffer>,
18953 {
18954 let (v0, v1, v2, v3) = self.0;
18955 SparseTensorBuilder((v0, v1, v2, v3, value))
18956 }
18957 }
18958
18959 impl<T0, T1, T2, T3, T4> SparseTensorBuilder<(T0, T1, T2, T3, T4)> {
18960 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SparseTensor].
18961 #[inline]
18962 pub fn finish(
18963 self,
18964 builder: &mut ::planus::Builder,
18965 ) -> ::planus::Offset<SparseTensor>
18966 where
18967 Self: ::planus::WriteAsOffset<SparseTensor>,
18968 {
18969 ::planus::WriteAsOffset::prepare(&self, builder)
18970 }
18971 }
18972
18973 impl<
18974 T0: ::planus::WriteAsUnion<self::Type>,
18975 T1: ::planus::WriteAs<
18976 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
18977 >,
18978 T2: ::planus::WriteAsDefault<i64, i64>,
18979 T3: ::planus::WriteAsUnion<self::SparseTensorIndex>,
18980 T4: ::planus::WriteAs<self::Buffer>,
18981 > ::planus::WriteAs<::planus::Offset<SparseTensor>>
18982 for SparseTensorBuilder<(T0, T1, T2, T3, T4)>
18983 {
18984 type Prepared = ::planus::Offset<SparseTensor>;
18985
18986 #[inline]
18987 fn prepare(
18988 &self,
18989 builder: &mut ::planus::Builder,
18990 ) -> ::planus::Offset<SparseTensor> {
18991 ::planus::WriteAsOffset::prepare(self, builder)
18992 }
18993 }
18994
18995 impl<
18996 T0: ::planus::WriteAsUnion<self::Type>,
18997 T1: ::planus::WriteAs<
18998 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
18999 >,
19000 T2: ::planus::WriteAsDefault<i64, i64>,
19001 T3: ::planus::WriteAsUnion<self::SparseTensorIndex>,
19002 T4: ::planus::WriteAs<self::Buffer>,
19003 >
19004 ::planus::WriteAsOptional<::planus::Offset<SparseTensor>>
19005 for SparseTensorBuilder<(T0, T1, T2, T3, T4)>
19006 {
19007 type Prepared = ::planus::Offset<SparseTensor>;
19008
19009 #[inline]
19010 fn prepare(
19011 &self,
19012 builder: &mut ::planus::Builder,
19013 ) -> ::core::option::Option<::planus::Offset<SparseTensor>>
19014 {
19015 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
19016 self, builder,
19017 ))
19018 }
19019 }
19020
19021 impl<
19022 T0: ::planus::WriteAsUnion<self::Type>,
19023 T1: ::planus::WriteAs<
19024 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
19025 >,
19026 T2: ::planus::WriteAsDefault<i64, i64>,
19027 T3: ::planus::WriteAsUnion<self::SparseTensorIndex>,
19028 T4: ::planus::WriteAs<self::Buffer>,
19029 > ::planus::WriteAsOffset<SparseTensor>
19030 for SparseTensorBuilder<(T0, T1, T2, T3, T4)>
19031 {
19032 #[inline]
19033 fn prepare(
19034 &self,
19035 builder: &mut ::planus::Builder,
19036 ) -> ::planus::Offset<SparseTensor> {
19037 let (v0, v1, v2, v3, v4) = &self.0;
19038 SparseTensor::create(builder, v0, v1, v2, v3, v4)
19039 }
19040 }
19041
19042 /// Reference to a deserialized [SparseTensor].
19043 #[derive(Copy, Clone)]
19044 pub struct SparseTensorRef<'a>(::planus::table_reader::Table<'a>);
19045
19046 impl<'a> SparseTensorRef<'a> {
19047 /// Getter for the [`type` field](SparseTensor#structfield.type_).
19048 #[inline]
19049 pub fn type_(&self) -> ::planus::Result<self::TypeRef<'a>> {
19050 self.0.access_union_required(0, "SparseTensor", "type_")
19051 }
19052
19053 /// Getter for the [`shape` field](SparseTensor#structfield.shape).
19054 #[inline]
19055 pub fn shape(
19056 &self,
19057 ) -> ::planus::Result<
19058 ::planus::Vector<'a, ::planus::Result<self::TensorDimRef<'a>>>,
19059 > {
19060 self.0.access_required(2, "SparseTensor", "shape")
19061 }
19062
19063 /// Getter for the [`non_zero_length` field](SparseTensor#structfield.non_zero_length).
19064 #[inline]
19065 pub fn non_zero_length(&self) -> ::planus::Result<i64> {
19066 ::core::result::Result::Ok(
19067 self.0
19068 .access(3, "SparseTensor", "non_zero_length")?
19069 .unwrap_or(0),
19070 )
19071 }
19072
19073 /// Getter for the [`sparseIndex` field](SparseTensor#structfield.sparse_index).
19074 #[inline]
19075 pub fn sparse_index(
19076 &self,
19077 ) -> ::planus::Result<self::SparseTensorIndexRef<'a>>
19078 {
19079 self.0
19080 .access_union_required(4, "SparseTensor", "sparse_index")
19081 }
19082
19083 /// Getter for the [`data` field](SparseTensor#structfield.data).
19084 #[inline]
19085 pub fn data(&self) -> ::planus::Result<self::BufferRef<'a>> {
19086 self.0.access_required(6, "SparseTensor", "data")
19087 }
19088 }
19089
19090 impl<'a> ::core::fmt::Debug for SparseTensorRef<'a> {
19091 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
19092 let mut f = f.debug_struct("SparseTensorRef");
19093 f.field("type_", &self.type_());
19094 f.field("shape", &self.shape());
19095 f.field("non_zero_length", &self.non_zero_length());
19096 f.field("sparse_index", &self.sparse_index());
19097 f.field("data", &self.data());
19098 f.finish()
19099 }
19100 }
19101
19102 impl<'a> ::core::convert::TryFrom<SparseTensorRef<'a>> for SparseTensor {
19103 type Error = ::planus::Error;
19104
19105 #[allow(unreachable_code)]
19106 fn try_from(value: SparseTensorRef<'a>) -> ::planus::Result<Self> {
19107 ::core::result::Result::Ok(Self {
19108 type_: ::core::convert::TryInto::try_into(value.type_()?)?,
19109 shape: value.shape()?.to_vec_result()?,
19110 non_zero_length: ::core::convert::TryInto::try_into(
19111 value.non_zero_length()?,
19112 )?,
19113 sparse_index: ::core::convert::TryInto::try_into(
19114 value.sparse_index()?,
19115 )?,
19116 data: ::core::convert::Into::into(value.data()?),
19117 })
19118 }
19119 }
19120
19121 impl<'a> ::planus::TableRead<'a> for SparseTensorRef<'a> {
19122 #[inline]
19123 fn from_buffer(
19124 buffer: ::planus::SliceWithStartOffset<'a>,
19125 offset: usize,
19126 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
19127 {
19128 ::core::result::Result::Ok(Self(
19129 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
19130 ))
19131 }
19132 }
19133
19134 impl<'a> ::planus::VectorReadInner<'a> for SparseTensorRef<'a> {
19135 type Error = ::planus::Error;
19136 const STRIDE: usize = 4;
19137
19138 unsafe fn from_buffer(
19139 buffer: ::planus::SliceWithStartOffset<'a>,
19140 offset: usize,
19141 ) -> ::planus::Result<Self> {
19142 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
19143 error_kind.with_error_location(
19144 "[SparseTensorRef]",
19145 "get",
19146 buffer.offset_from_start,
19147 )
19148 })
19149 }
19150 }
19151
19152 /// # Safety
19153 /// The planus compiler generates implementations that initialize
19154 /// the bytes in `write_values`.
19155 unsafe impl ::planus::VectorWrite<::planus::Offset<SparseTensor>> for SparseTensor {
19156 type Value = ::planus::Offset<SparseTensor>;
19157 const STRIDE: usize = 4;
19158 #[inline]
19159 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
19160 ::planus::WriteAs::prepare(self, builder)
19161 }
19162
19163 #[inline]
19164 unsafe fn write_values(
19165 values: &[::planus::Offset<SparseTensor>],
19166 bytes: *mut ::core::mem::MaybeUninit<u8>,
19167 buffer_position: u32,
19168 ) {
19169 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
19170 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
19171 ::planus::WriteAsPrimitive::write(
19172 v,
19173 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
19174 buffer_position - (Self::STRIDE * i) as u32,
19175 );
19176 }
19177 }
19178 }
19179
19180 impl<'a> ::planus::ReadAsRoot<'a> for SparseTensorRef<'a> {
19181 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
19182 ::planus::TableRead::from_buffer(
19183 ::planus::SliceWithStartOffset {
19184 buffer: slice,
19185 offset_from_start: 0,
19186 },
19187 0,
19188 )
19189 .map_err(|error_kind| {
19190 error_kind.with_error_location(
19191 "[SparseTensorRef]",
19192 "read_as_root",
19193 0,
19194 )
19195 })
19196 }
19197 }
19198
19199 /// ----------------------------------------------------------------------
19200 /// Data structures for dense tensors
19201 /// Shape data for a single axis in a tensor
19202 ///
19203 /// Generated from these locations:
19204 /// * Table `TensorDim` in the file `Tensor.fbs:30`
19205 #[derive(
19206 Clone,
19207 Debug,
19208 PartialEq,
19209 PartialOrd,
19210 Eq,
19211 Ord,
19212 Hash,
19213 ::serde::Serialize,
19214 ::serde::Deserialize,
19215 )]
19216 pub struct TensorDim {
19217 /// Length of dimension
19218 pub size: i64,
19219 /// Name of the dimension, optional
19220 pub name: ::core::option::Option<::planus::alloc::string::String>,
19221 }
19222
19223 #[allow(clippy::derivable_impls)]
19224 impl ::core::default::Default for TensorDim {
19225 fn default() -> Self {
19226 Self {
19227 size: 0,
19228 name: ::core::default::Default::default(),
19229 }
19230 }
19231 }
19232
19233 impl TensorDim {
19234 /// Creates a [TensorDimBuilder] for serializing an instance of this table.
19235 #[inline]
19236 pub fn builder() -> TensorDimBuilder<()> {
19237 TensorDimBuilder(())
19238 }
19239
19240 #[allow(clippy::too_many_arguments)]
19241 pub fn create(
19242 builder: &mut ::planus::Builder,
19243 field_size: impl ::planus::WriteAsDefault<i64, i64>,
19244 field_name: impl ::planus::WriteAsOptional<
19245 ::planus::Offset<::core::primitive::str>,
19246 >,
19247 ) -> ::planus::Offset<Self> {
19248 let prepared_size = field_size.prepare(builder, &0);
19249 let prepared_name = field_name.prepare(builder);
19250
19251 let mut table_writer: ::planus::table_writer::TableWriter<8> =
19252 ::core::default::Default::default();
19253 if prepared_size.is_some() {
19254 table_writer.write_entry::<i64>(0);
19255 }
19256 if prepared_name.is_some() {
19257 table_writer.write_entry::<::planus::Offset<str>>(1);
19258 }
19259
19260 unsafe {
19261 table_writer.finish(builder, |object_writer| {
19262 if let ::core::option::Option::Some(prepared_size) =
19263 prepared_size
19264 {
19265 object_writer.write::<_, _, 8>(&prepared_size);
19266 }
19267 if let ::core::option::Option::Some(prepared_name) =
19268 prepared_name
19269 {
19270 object_writer.write::<_, _, 4>(&prepared_name);
19271 }
19272 });
19273 }
19274 builder.current_offset()
19275 }
19276 }
19277
19278 impl ::planus::WriteAs<::planus::Offset<TensorDim>> for TensorDim {
19279 type Prepared = ::planus::Offset<Self>;
19280
19281 #[inline]
19282 fn prepare(
19283 &self,
19284 builder: &mut ::planus::Builder,
19285 ) -> ::planus::Offset<TensorDim> {
19286 ::planus::WriteAsOffset::prepare(self, builder)
19287 }
19288 }
19289
19290 impl ::planus::WriteAsOptional<::planus::Offset<TensorDim>> for TensorDim {
19291 type Prepared = ::planus::Offset<Self>;
19292
19293 #[inline]
19294 fn prepare(
19295 &self,
19296 builder: &mut ::planus::Builder,
19297 ) -> ::core::option::Option<::planus::Offset<TensorDim>>
19298 {
19299 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
19300 self, builder,
19301 ))
19302 }
19303 }
19304
19305 impl ::planus::WriteAsOffset<TensorDim> for TensorDim {
19306 #[inline]
19307 fn prepare(
19308 &self,
19309 builder: &mut ::planus::Builder,
19310 ) -> ::planus::Offset<TensorDim> {
19311 TensorDim::create(builder, self.size, &self.name)
19312 }
19313 }
19314
19315 /// Builder for serializing an instance of the [TensorDim] type.
19316 ///
19317 /// Can be created using the [TensorDim::builder] method.
19318 #[derive(Debug)]
19319 #[must_use]
19320 pub struct TensorDimBuilder<State>(State);
19321
19322 impl TensorDimBuilder<()> {
19323 /// Setter for the [`size` field](TensorDim#structfield.size).
19324 #[inline]
19325 #[allow(clippy::type_complexity)]
19326 pub fn size<T0>(self, value: T0) -> TensorDimBuilder<(T0,)>
19327 where
19328 T0: ::planus::WriteAsDefault<i64, i64>,
19329 {
19330 TensorDimBuilder((value,))
19331 }
19332
19333 /// Sets the [`size` field](TensorDim#structfield.size) to the default value.
19334 #[inline]
19335 #[allow(clippy::type_complexity)]
19336 pub fn size_as_default(
19337 self,
19338 ) -> TensorDimBuilder<(::planus::DefaultValue,)> {
19339 self.size(::planus::DefaultValue)
19340 }
19341 }
19342
19343 impl<T0> TensorDimBuilder<(T0,)> {
19344 /// Setter for the [`name` field](TensorDim#structfield.name).
19345 #[inline]
19346 #[allow(clippy::type_complexity)]
19347 pub fn name<T1>(self, value: T1) -> TensorDimBuilder<(T0, T1)>
19348 where
19349 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
19350 {
19351 let (v0,) = self.0;
19352 TensorDimBuilder((v0, value))
19353 }
19354
19355 /// Sets the [`name` field](TensorDim#structfield.name) to null.
19356 #[inline]
19357 #[allow(clippy::type_complexity)]
19358 pub fn name_as_null(self) -> TensorDimBuilder<(T0, ())> {
19359 self.name(())
19360 }
19361 }
19362
19363 impl<T0, T1> TensorDimBuilder<(T0, T1)> {
19364 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TensorDim].
19365 #[inline]
19366 pub fn finish(
19367 self,
19368 builder: &mut ::planus::Builder,
19369 ) -> ::planus::Offset<TensorDim>
19370 where
19371 Self: ::planus::WriteAsOffset<TensorDim>,
19372 {
19373 ::planus::WriteAsOffset::prepare(&self, builder)
19374 }
19375 }
19376
19377 impl<
19378 T0: ::planus::WriteAsDefault<i64, i64>,
19379 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
19380 > ::planus::WriteAs<::planus::Offset<TensorDim>>
19381 for TensorDimBuilder<(T0, T1)>
19382 {
19383 type Prepared = ::planus::Offset<TensorDim>;
19384
19385 #[inline]
19386 fn prepare(
19387 &self,
19388 builder: &mut ::planus::Builder,
19389 ) -> ::planus::Offset<TensorDim> {
19390 ::planus::WriteAsOffset::prepare(self, builder)
19391 }
19392 }
19393
19394 impl<
19395 T0: ::planus::WriteAsDefault<i64, i64>,
19396 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
19397 > ::planus::WriteAsOptional<::planus::Offset<TensorDim>>
19398 for TensorDimBuilder<(T0, T1)>
19399 {
19400 type Prepared = ::planus::Offset<TensorDim>;
19401
19402 #[inline]
19403 fn prepare(
19404 &self,
19405 builder: &mut ::planus::Builder,
19406 ) -> ::core::option::Option<::planus::Offset<TensorDim>>
19407 {
19408 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
19409 self, builder,
19410 ))
19411 }
19412 }
19413
19414 impl<
19415 T0: ::planus::WriteAsDefault<i64, i64>,
19416 T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>,
19417 > ::planus::WriteAsOffset<TensorDim> for TensorDimBuilder<(T0, T1)>
19418 {
19419 #[inline]
19420 fn prepare(
19421 &self,
19422 builder: &mut ::planus::Builder,
19423 ) -> ::planus::Offset<TensorDim> {
19424 let (v0, v1) = &self.0;
19425 TensorDim::create(builder, v0, v1)
19426 }
19427 }
19428
19429 /// Reference to a deserialized [TensorDim].
19430 #[derive(Copy, Clone)]
19431 pub struct TensorDimRef<'a>(::planus::table_reader::Table<'a>);
19432
19433 impl<'a> TensorDimRef<'a> {
19434 /// Getter for the [`size` field](TensorDim#structfield.size).
19435 #[inline]
19436 pub fn size(&self) -> ::planus::Result<i64> {
19437 ::core::result::Result::Ok(
19438 self.0.access(0, "TensorDim", "size")?.unwrap_or(0),
19439 )
19440 }
19441
19442 /// Getter for the [`name` field](TensorDim#structfield.name).
19443 #[inline]
19444 pub fn name(
19445 &self,
19446 ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>>
19447 {
19448 self.0.access(1, "TensorDim", "name")
19449 }
19450 }
19451
19452 impl<'a> ::core::fmt::Debug for TensorDimRef<'a> {
19453 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
19454 let mut f = f.debug_struct("TensorDimRef");
19455 f.field("size", &self.size());
19456 if let ::core::option::Option::Some(field_name) =
19457 self.name().transpose()
19458 {
19459 f.field("name", &field_name);
19460 }
19461 f.finish()
19462 }
19463 }
19464
19465 impl<'a> ::core::convert::TryFrom<TensorDimRef<'a>> for TensorDim {
19466 type Error = ::planus::Error;
19467
19468 #[allow(unreachable_code)]
19469 fn try_from(value: TensorDimRef<'a>) -> ::planus::Result<Self> {
19470 ::core::result::Result::Ok(Self {
19471 size: ::core::convert::TryInto::try_into(value.size()?)?,
19472 name: value.name()?.map(::core::convert::Into::into),
19473 })
19474 }
19475 }
19476
19477 impl<'a> ::planus::TableRead<'a> for TensorDimRef<'a> {
19478 #[inline]
19479 fn from_buffer(
19480 buffer: ::planus::SliceWithStartOffset<'a>,
19481 offset: usize,
19482 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
19483 {
19484 ::core::result::Result::Ok(Self(
19485 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
19486 ))
19487 }
19488 }
19489
19490 impl<'a> ::planus::VectorReadInner<'a> for TensorDimRef<'a> {
19491 type Error = ::planus::Error;
19492 const STRIDE: usize = 4;
19493
19494 unsafe fn from_buffer(
19495 buffer: ::planus::SliceWithStartOffset<'a>,
19496 offset: usize,
19497 ) -> ::planus::Result<Self> {
19498 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
19499 error_kind.with_error_location(
19500 "[TensorDimRef]",
19501 "get",
19502 buffer.offset_from_start,
19503 )
19504 })
19505 }
19506 }
19507
19508 /// # Safety
19509 /// The planus compiler generates implementations that initialize
19510 /// the bytes in `write_values`.
19511 unsafe impl ::planus::VectorWrite<::planus::Offset<TensorDim>> for TensorDim {
19512 type Value = ::planus::Offset<TensorDim>;
19513 const STRIDE: usize = 4;
19514 #[inline]
19515 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
19516 ::planus::WriteAs::prepare(self, builder)
19517 }
19518
19519 #[inline]
19520 unsafe fn write_values(
19521 values: &[::planus::Offset<TensorDim>],
19522 bytes: *mut ::core::mem::MaybeUninit<u8>,
19523 buffer_position: u32,
19524 ) {
19525 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
19526 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
19527 ::planus::WriteAsPrimitive::write(
19528 v,
19529 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
19530 buffer_position - (Self::STRIDE * i) as u32,
19531 );
19532 }
19533 }
19534 }
19535
19536 impl<'a> ::planus::ReadAsRoot<'a> for TensorDimRef<'a> {
19537 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
19538 ::planus::TableRead::from_buffer(
19539 ::planus::SliceWithStartOffset {
19540 buffer: slice,
19541 offset_from_start: 0,
19542 },
19543 0,
19544 )
19545 .map_err(|error_kind| {
19546 error_kind.with_error_location("[TensorDimRef]", "read_as_root", 0)
19547 })
19548 }
19549 }
19550
19551 /// The table `Tensor` in the namespace `org.apache.arrow.flatbuf`
19552 ///
19553 /// Generated from these locations:
19554 /// * Table `Tensor` in the file `Tensor.fbs:38`
19555 #[derive(
19556 Clone,
19557 Debug,
19558 PartialEq,
19559 PartialOrd,
19560 Eq,
19561 Ord,
19562 Hash,
19563 ::serde::Serialize,
19564 ::serde::Deserialize,
19565 )]
19566 pub struct Tensor {
19567 /// The type of data contained in a value cell. Currently only fixed-width
19568 /// value types are supported, no strings or nested types
19569 pub type_: self::Type,
19570 /// The dimensions of the tensor, optionally named
19571 pub shape: ::planus::alloc::vec::Vec<self::TensorDim>,
19572 /// Non-negative byte offsets to advance one value cell along each dimension
19573 /// If omitted, default to row-major order (C-like).
19574 pub strides: ::core::option::Option<::planus::alloc::vec::Vec<i64>>,
19575 /// The location and size of the tensor's data
19576 pub data: self::Buffer,
19577 }
19578
19579 impl Tensor {
19580 /// Creates a [TensorBuilder] for serializing an instance of this table.
19581 #[inline]
19582 pub fn builder() -> TensorBuilder<()> {
19583 TensorBuilder(())
19584 }
19585
19586 #[allow(clippy::too_many_arguments)]
19587 pub fn create(
19588 builder: &mut ::planus::Builder,
19589 field_type_: impl ::planus::WriteAsUnion<self::Type>,
19590 field_shape: impl ::planus::WriteAs<
19591 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
19592 >,
19593 field_strides: impl ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
19594 field_data: impl ::planus::WriteAs<self::Buffer>,
19595 ) -> ::planus::Offset<Self> {
19596 let prepared_type_ = field_type_.prepare(builder);
19597 let prepared_shape = field_shape.prepare(builder);
19598 let prepared_strides = field_strides.prepare(builder);
19599 let prepared_data = field_data.prepare(builder);
19600
19601 let mut table_writer: ::planus::table_writer::TableWriter<14> =
19602 ::core::default::Default::default();
19603 table_writer.write_entry::<self::Buffer>(4);
19604 table_writer.write_entry::<::planus::Offset<self::Type>>(1);
19605 table_writer.write_entry::<::planus::Offset<[::planus::Offset<self::TensorDim>]>>(2);
19606 if prepared_strides.is_some() {
19607 table_writer.write_entry::<::planus::Offset<[i64]>>(3);
19608 }
19609 table_writer.write_entry::<u8>(0);
19610
19611 unsafe {
19612 table_writer.finish(builder, |object_writer| {
19613 object_writer.write::<_, _, 16>(&prepared_data);
19614 object_writer.write::<_, _, 4>(&prepared_type_.offset());
19615 object_writer.write::<_, _, 4>(&prepared_shape);
19616 if let ::core::option::Option::Some(prepared_strides) =
19617 prepared_strides
19618 {
19619 object_writer.write::<_, _, 4>(&prepared_strides);
19620 }
19621 object_writer.write::<_, _, 1>(&prepared_type_.tag());
19622 });
19623 }
19624 builder.current_offset()
19625 }
19626 }
19627
19628 impl ::planus::WriteAs<::planus::Offset<Tensor>> for Tensor {
19629 type Prepared = ::planus::Offset<Self>;
19630
19631 #[inline]
19632 fn prepare(
19633 &self,
19634 builder: &mut ::planus::Builder,
19635 ) -> ::planus::Offset<Tensor> {
19636 ::planus::WriteAsOffset::prepare(self, builder)
19637 }
19638 }
19639
19640 impl ::planus::WriteAsOptional<::planus::Offset<Tensor>> for Tensor {
19641 type Prepared = ::planus::Offset<Self>;
19642
19643 #[inline]
19644 fn prepare(
19645 &self,
19646 builder: &mut ::planus::Builder,
19647 ) -> ::core::option::Option<::planus::Offset<Tensor>>
19648 {
19649 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
19650 self, builder,
19651 ))
19652 }
19653 }
19654
19655 impl ::planus::WriteAsOffset<Tensor> for Tensor {
19656 #[inline]
19657 fn prepare(
19658 &self,
19659 builder: &mut ::planus::Builder,
19660 ) -> ::planus::Offset<Tensor> {
19661 Tensor::create(
19662 builder,
19663 &self.type_,
19664 &self.shape,
19665 &self.strides,
19666 self.data,
19667 )
19668 }
19669 }
19670
19671 /// Builder for serializing an instance of the [Tensor] type.
19672 ///
19673 /// Can be created using the [Tensor::builder] method.
19674 #[derive(Debug)]
19675 #[must_use]
19676 pub struct TensorBuilder<State>(State);
19677
19678 impl TensorBuilder<()> {
19679 /// Setter for the [`type` field](Tensor#structfield.type_).
19680 #[inline]
19681 #[allow(clippy::type_complexity)]
19682 pub fn type_<T0>(self, value: T0) -> TensorBuilder<(T0,)>
19683 where
19684 T0: ::planus::WriteAsUnion<self::Type>,
19685 {
19686 TensorBuilder((value,))
19687 }
19688 }
19689
19690 impl<T0> TensorBuilder<(T0,)> {
19691 /// Setter for the [`shape` field](Tensor#structfield.shape).
19692 #[inline]
19693 #[allow(clippy::type_complexity)]
19694 pub fn shape<T1>(self, value: T1) -> TensorBuilder<(T0, T1)>
19695 where
19696 T1: ::planus::WriteAs<
19697 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
19698 >,
19699 {
19700 let (v0,) = self.0;
19701 TensorBuilder((v0, value))
19702 }
19703 }
19704
19705 impl<T0, T1> TensorBuilder<(T0, T1)> {
19706 /// Setter for the [`strides` field](Tensor#structfield.strides).
19707 #[inline]
19708 #[allow(clippy::type_complexity)]
19709 pub fn strides<T2>(self, value: T2) -> TensorBuilder<(T0, T1, T2)>
19710 where
19711 T2: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
19712 {
19713 let (v0, v1) = self.0;
19714 TensorBuilder((v0, v1, value))
19715 }
19716
19717 /// Sets the [`strides` field](Tensor#structfield.strides) to null.
19718 #[inline]
19719 #[allow(clippy::type_complexity)]
19720 pub fn strides_as_null(self) -> TensorBuilder<(T0, T1, ())> {
19721 self.strides(())
19722 }
19723 }
19724
19725 impl<T0, T1, T2> TensorBuilder<(T0, T1, T2)> {
19726 /// Setter for the [`data` field](Tensor#structfield.data).
19727 #[inline]
19728 #[allow(clippy::type_complexity)]
19729 pub fn data<T3>(self, value: T3) -> TensorBuilder<(T0, T1, T2, T3)>
19730 where
19731 T3: ::planus::WriteAs<self::Buffer>,
19732 {
19733 let (v0, v1, v2) = self.0;
19734 TensorBuilder((v0, v1, v2, value))
19735 }
19736 }
19737
19738 impl<T0, T1, T2, T3> TensorBuilder<(T0, T1, T2, T3)> {
19739 /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Tensor].
19740 #[inline]
19741 pub fn finish(
19742 self,
19743 builder: &mut ::planus::Builder,
19744 ) -> ::planus::Offset<Tensor>
19745 where
19746 Self: ::planus::WriteAsOffset<Tensor>,
19747 {
19748 ::planus::WriteAsOffset::prepare(&self, builder)
19749 }
19750 }
19751
19752 impl<
19753 T0: ::planus::WriteAsUnion<self::Type>,
19754 T1: ::planus::WriteAs<
19755 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
19756 >,
19757 T2: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
19758 T3: ::planus::WriteAs<self::Buffer>,
19759 > ::planus::WriteAs<::planus::Offset<Tensor>>
19760 for TensorBuilder<(T0, T1, T2, T3)>
19761 {
19762 type Prepared = ::planus::Offset<Tensor>;
19763
19764 #[inline]
19765 fn prepare(
19766 &self,
19767 builder: &mut ::planus::Builder,
19768 ) -> ::planus::Offset<Tensor> {
19769 ::planus::WriteAsOffset::prepare(self, builder)
19770 }
19771 }
19772
19773 impl<
19774 T0: ::planus::WriteAsUnion<self::Type>,
19775 T1: ::planus::WriteAs<
19776 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
19777 >,
19778 T2: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
19779 T3: ::planus::WriteAs<self::Buffer>,
19780 > ::planus::WriteAsOptional<::planus::Offset<Tensor>>
19781 for TensorBuilder<(T0, T1, T2, T3)>
19782 {
19783 type Prepared = ::planus::Offset<Tensor>;
19784
19785 #[inline]
19786 fn prepare(
19787 &self,
19788 builder: &mut ::planus::Builder,
19789 ) -> ::core::option::Option<::planus::Offset<Tensor>>
19790 {
19791 ::core::option::Option::Some(::planus::WriteAsOffset::prepare(
19792 self, builder,
19793 ))
19794 }
19795 }
19796
19797 impl<
19798 T0: ::planus::WriteAsUnion<self::Type>,
19799 T1: ::planus::WriteAs<
19800 ::planus::Offset<[::planus::Offset<self::TensorDim>]>,
19801 >,
19802 T2: ::planus::WriteAsOptional<::planus::Offset<[i64]>>,
19803 T3: ::planus::WriteAs<self::Buffer>,
19804 > ::planus::WriteAsOffset<Tensor> for TensorBuilder<(T0, T1, T2, T3)>
19805 {
19806 #[inline]
19807 fn prepare(
19808 &self,
19809 builder: &mut ::planus::Builder,
19810 ) -> ::planus::Offset<Tensor> {
19811 let (v0, v1, v2, v3) = &self.0;
19812 Tensor::create(builder, v0, v1, v2, v3)
19813 }
19814 }
19815
19816 /// Reference to a deserialized [Tensor].
19817 #[derive(Copy, Clone)]
19818 pub struct TensorRef<'a>(::planus::table_reader::Table<'a>);
19819
19820 impl<'a> TensorRef<'a> {
19821 /// Getter for the [`type` field](Tensor#structfield.type_).
19822 #[inline]
19823 pub fn type_(&self) -> ::planus::Result<self::TypeRef<'a>> {
19824 self.0.access_union_required(0, "Tensor", "type_")
19825 }
19826
19827 /// Getter for the [`shape` field](Tensor#structfield.shape).
19828 #[inline]
19829 pub fn shape(
19830 &self,
19831 ) -> ::planus::Result<
19832 ::planus::Vector<'a, ::planus::Result<self::TensorDimRef<'a>>>,
19833 > {
19834 self.0.access_required(2, "Tensor", "shape")
19835 }
19836
19837 /// Getter for the [`strides` field](Tensor#structfield.strides).
19838 #[inline]
19839 pub fn strides(
19840 &self,
19841 ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i64>>>
19842 {
19843 self.0.access(3, "Tensor", "strides")
19844 }
19845
19846 /// Getter for the [`data` field](Tensor#structfield.data).
19847 #[inline]
19848 pub fn data(&self) -> ::planus::Result<self::BufferRef<'a>> {
19849 self.0.access_required(4, "Tensor", "data")
19850 }
19851 }
19852
19853 impl<'a> ::core::fmt::Debug for TensorRef<'a> {
19854 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
19855 let mut f = f.debug_struct("TensorRef");
19856 f.field("type_", &self.type_());
19857 f.field("shape", &self.shape());
19858 if let ::core::option::Option::Some(field_strides) =
19859 self.strides().transpose()
19860 {
19861 f.field("strides", &field_strides);
19862 }
19863 f.field("data", &self.data());
19864 f.finish()
19865 }
19866 }
19867
19868 impl<'a> ::core::convert::TryFrom<TensorRef<'a>> for Tensor {
19869 type Error = ::planus::Error;
19870
19871 #[allow(unreachable_code)]
19872 fn try_from(value: TensorRef<'a>) -> ::planus::Result<Self> {
19873 ::core::result::Result::Ok(Self {
19874 type_: ::core::convert::TryInto::try_into(value.type_()?)?,
19875 shape: value.shape()?.to_vec_result()?,
19876 strides: if let ::core::option::Option::Some(strides) =
19877 value.strides()?
19878 {
19879 ::core::option::Option::Some(strides.to_vec()?)
19880 } else {
19881 ::core::option::Option::None
19882 },
19883 data: ::core::convert::Into::into(value.data()?),
19884 })
19885 }
19886 }
19887
19888 impl<'a> ::planus::TableRead<'a> for TensorRef<'a> {
19889 #[inline]
19890 fn from_buffer(
19891 buffer: ::planus::SliceWithStartOffset<'a>,
19892 offset: usize,
19893 ) -> ::core::result::Result<Self, ::planus::errors::ErrorKind>
19894 {
19895 ::core::result::Result::Ok(Self(
19896 ::planus::table_reader::Table::from_buffer(buffer, offset)?,
19897 ))
19898 }
19899 }
19900
19901 impl<'a> ::planus::VectorReadInner<'a> for TensorRef<'a> {
19902 type Error = ::planus::Error;
19903 const STRIDE: usize = 4;
19904
19905 unsafe fn from_buffer(
19906 buffer: ::planus::SliceWithStartOffset<'a>,
19907 offset: usize,
19908 ) -> ::planus::Result<Self> {
19909 ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| {
19910 error_kind.with_error_location(
19911 "[TensorRef]",
19912 "get",
19913 buffer.offset_from_start,
19914 )
19915 })
19916 }
19917 }
19918
19919 /// # Safety
19920 /// The planus compiler generates implementations that initialize
19921 /// the bytes in `write_values`.
19922 unsafe impl ::planus::VectorWrite<::planus::Offset<Tensor>> for Tensor {
19923 type Value = ::planus::Offset<Tensor>;
19924 const STRIDE: usize = 4;
19925 #[inline]
19926 fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value {
19927 ::planus::WriteAs::prepare(self, builder)
19928 }
19929
19930 #[inline]
19931 unsafe fn write_values(
19932 values: &[::planus::Offset<Tensor>],
19933 bytes: *mut ::core::mem::MaybeUninit<u8>,
19934 buffer_position: u32,
19935 ) {
19936 let bytes = bytes as *mut [::core::mem::MaybeUninit<u8>; 4];
19937 for (i, v) in ::core::iter::Iterator::enumerate(values.iter()) {
19938 ::planus::WriteAsPrimitive::write(
19939 v,
19940 ::planus::Cursor::new(unsafe { &mut *bytes.add(i) }),
19941 buffer_position - (Self::STRIDE * i) as u32,
19942 );
19943 }
19944 }
19945 }
19946
19947 impl<'a> ::planus::ReadAsRoot<'a> for TensorRef<'a> {
19948 fn read_as_root(slice: &'a [u8]) -> ::planus::Result<Self> {
19949 ::planus::TableRead::from_buffer(
19950 ::planus::SliceWithStartOffset {
19951 buffer: slice,
19952 offset_from_start: 0,
19953 },
19954 0,
19955 )
19956 .map_err(|error_kind| {
19957 error_kind.with_error_location("[TensorRef]", "read_as_root", 0)
19958 })
19959 }
19960 }
19961 }
19962 }
19963 }
19964 }
19965}