1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#![cfg_attr(not(feature = "std"), no_std)]
mod backvec;
mod builder;
mod impls;
mod slice_helpers;
mod traits;
pub mod errors;
pub mod vectors;
#[doc(hidden)]
pub extern crate alloc;
#[doc(hidden)]
pub mod table_reader;
#[doc(hidden)]
pub mod table_writer;
pub use crate::{
builder::Builder,
errors::Error,
slice_helpers::{ArrayWithStartOffset, SliceWithStartOffset},
traits::*,
vectors::Vector,
};
pub type Result<T> = core::result::Result<T, Error>;
#[doc(hidden)]
pub type Cursor<'a, const N: usize> = array_init_cursor::Cursor<'a, u8, N>;
#[doc(hidden)]
pub enum Void {}
impl From<Void> for crate::Error {
fn from(v: Void) -> Self {
match v {}
}
}
pub struct Offset<T: ?Sized> {
offset: u32,
phantom: core::marker::PhantomData<T>,
}
impl<T: ?Sized> Copy for Offset<T> {}
impl<T: ?Sized> Clone for Offset<T> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
pub struct UnionOffset<T: ?Sized> {
tag: u8,
offset: Offset<()>,
phantom: core::marker::PhantomData<T>,
}
impl<T: ?Sized> Copy for UnionOffset<T> {}
impl<T: ?Sized> Clone for UnionOffset<T> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<T: ?Sized> Offset<T> {
#[doc(hidden)]
pub fn downcast(&self) -> Offset<()> {
Offset {
offset: self.offset,
phantom: core::marker::PhantomData,
}
}
}
impl<T: ?Sized> UnionOffset<T> {
#[doc(hidden)]
#[inline]
pub fn new(tag: u8, offset: Offset<()>) -> UnionOffset<T> {
Self {
tag,
offset,
phantom: core::marker::PhantomData,
}
}
#[doc(hidden)]
#[inline]
pub fn tag(&self) -> u8 {
self.tag
}
#[doc(hidden)]
#[inline]
pub fn offset(&self) -> Offset<()> {
self.offset
}
}