#[repr(u8)]pub enum FlexBufferType {
Show 27 variants
Null = 0,
Int = 1,
UInt = 2,
Float = 3,
Bool = 26,
Key = 4,
String = 5,
IndirectInt = 6,
IndirectUInt = 7,
IndirectFloat = 8,
Map = 9,
Vector = 10,
VectorInt = 11,
VectorUInt = 12,
VectorFloat = 13,
VectorKey = 14,
VectorBool = 36,
VectorInt2 = 16,
VectorUInt2 = 17,
VectorFloat2 = 18,
VectorInt3 = 19,
VectorUInt3 = 20,
VectorFloat3 = 21,
VectorInt4 = 22,
VectorUInt4 = 23,
VectorFloat4 = 24,
Blob = 25,
}Expand description
Represents all the valid types in a flexbuffer.
Flexbuffers supports heterogenous maps, heterogenous vectors, typed vectors, and fixed length typed vectors for some lengths and types. Rust types are converted into Flexbuffers via the Pushable trait.
For exact details see the internals document
§Notes:
-
In the binary format, Each element of a
Mapor (heterogenous)Vectoris stored with a byte describing itsFlexBufferTypeandBitWidth. -
Typed vectors do not store this extra type information and fixed length typed vectors do not store length. Whether a vector is stored as a typed vector or fixed length typed vector is determined dymaically from the given data.
-
Indirect numbers are stored as an offset instead of inline. Using indirect numbers instead of their inline counterparts in maps and typed vectors can reduce the minimum element width and therefore bytes used.
Variants§
Null = 0
Nulls are represented with () in Rust.
Int = 1
Variable width signed integer: i8, i16, i32, i64
UInt = 2
Variable width unsigned integer: u8, u16, u32, u64
Float = 3
Variable width floating point: f32, f64
Bool = 26
Key = 4
Null termintated, utf8 string. Typically used with Maps.
String = 5
Stored with a unsigned integer length, then UTF-8 bytes, and an extra null terminator that is not counted with the length.
IndirectInt = 6
An Int, stored by offset rather than inline. Indirect types can keep the bitwidth of a vector or map small when the inline value would have increased the bitwidth.
IndirectUInt = 7
A UInt, stored by offset rather than inline. Indirect types can keep the bitwidth of a
vector or map small when the inline value would have increased the bitwidth.
IndirectFloat = 8
A Float, stored by offset rather than inline. Indirect types can keep the bitwidth of a vector or map small when the inline value would have increased the bitwidth.
Map = 9
Maps are like Vectors except elements are associated with, and sorted by, keys.
Vector = 10
Heterogenous Vector (stored with a type table).
VectorInt = 11
Homogenous Vector of Ints.
VectorUInt = 12
Homogenous Vector of UInts.
VectorFloat = 13
Homogenous Vector of Floats.
VectorKey = 14
Homogenous Vector of Keys.
VectorBool = 36
Since the elements of a vector use the same BitWidth as the length,
Blob is more efficient for >255 element boolean vectors.
VectorInt2 = 16
Homogenous vector of two Ints
VectorUInt2 = 17
Homogenous vector of two UInts
VectorFloat2 = 18
Homogenous vector of two Floats
VectorInt3 = 19
Homogenous vector of three Ints
VectorUInt3 = 20
Homogenous vector of three UInts
VectorFloat3 = 21
Homogenous vector of three Floats
VectorInt4 = 22
Homogenous vector of four Ints
VectorUInt4 = 23
Homogenous vector of four UInts
VectorFloat4 = 24
Homogenous vector of four Floats
Blob = 25
An array of bytes. Stored with a variable width length.
Implementations§
Source§impl FlexBufferType
impl FlexBufferType
Sourcepub fn is_reference(self) -> bool
pub fn is_reference(self) -> bool
Returns true for flexbuffer types that are stored by offset.
Sourcepub fn is_vector(self) -> bool
pub fn is_vector(self) -> bool
Returns true if called on a map, vector, typed vector, or fixed length typed vector.
Sourcepub fn has_length_slot(self) -> bool
pub fn has_length_slot(self) -> bool
True iff the binary format stores the length. This applies to Blob, String, Maps, and Vectors of variable length.
Sourcepub fn is_fixed_length_vector(self) -> bool
pub fn is_fixed_length_vector(self) -> bool
Returns true if called on a fixed length typed vector.
Sourcepub fn typed_vector_type(self) -> Option<FlexBufferType>
pub fn typed_vector_type(self) -> Option<FlexBufferType>
If called on a fixed type vector, returns the type of the elements.
Sourcepub fn fixed_length_vector_length(self) -> Option<usize>
pub fn fixed_length_vector_length(self) -> Option<usize>
Return the length of the fixed length vector or None.
Sourcepub fn is_heterogenous(self) -> bool
pub fn is_heterogenous(self) -> bool
Returns true if self is a Map or Vector. Typed vectors are not heterogenous.
Sourcepub fn to_direct(self) -> Option<Self>
pub fn to_direct(self) -> Option<Self>
If self is an indirect scalar, remap it to the scalar. Otherwise do nothing.
pub fn is_null(self) -> bool
pub fn is_int(self) -> bool
pub fn is_uint(self) -> bool
pub fn is_float(self) -> bool
pub fn is_bool(self) -> bool
pub fn is_key(self) -> bool
pub fn is_string(self) -> bool
pub fn is_indirect_int(self) -> bool
pub fn is_indirect_uint(self) -> bool
pub fn is_indirect_float(self) -> bool
pub fn is_map(self) -> bool
pub fn is_heterogenous_vector(self) -> bool
pub fn is_vector_int(self) -> bool
pub fn is_vector_uint(self) -> bool
pub fn is_vector_float(self) -> bool
pub fn is_vector_key(self) -> bool
pub fn is_vector_bool(self) -> bool
pub fn is_vector_int2(self) -> bool
pub fn is_vector_uint2(self) -> bool
pub fn is_vector_float2(self) -> bool
pub fn is_vector_int3(self) -> bool
pub fn is_vector_uint3(self) -> bool
pub fn is_vector_float3(self) -> bool
pub fn is_vector_int4(self) -> bool
pub fn is_vector_uint4(self) -> bool
pub fn is_vector_float4(self) -> bool
pub fn is_blob(self) -> bool
Trait Implementations§
Source§impl Clone for FlexBufferType
impl Clone for FlexBufferType
Source§fn clone(&self) -> FlexBufferType
fn clone(&self) -> FlexBufferType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more