FlexBufferType

Enum FlexBufferType 

Source
#[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 Map or (heterogenous) Vector is stored with a byte describing its FlexBufferType and BitWidth.

  • 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

Source

pub fn is_inline(self) -> bool

Returns true for flexbuffer types that are stored inline.

Source

pub fn is_reference(self) -> bool

Returns true for flexbuffer types that are stored by offset.

Source

pub fn is_vector(self) -> bool

Returns true if called on a map, vector, typed vector, or fixed length typed vector.

Source

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.

Source

pub fn is_fixed_length_vector(self) -> bool

Returns true if called on a fixed length typed vector.

Source

pub fn typed_vector_type(self) -> Option<FlexBufferType>

If called on a fixed type vector, returns the type of the elements.

Source

pub fn fixed_length_vector_length(self) -> Option<usize>

Return the length of the fixed length vector or None.

Source

pub fn is_heterogenous(self) -> bool

Returns true if self is a Map or Vector. Typed vectors are not heterogenous.

Source

pub fn to_direct(self) -> Option<Self>

If self is an indirect scalar, remap it to the scalar. Otherwise do nothing.

Source

pub fn is_null(self) -> bool

Source

pub fn is_int(self) -> bool

Source

pub fn is_uint(self) -> bool

Source

pub fn is_float(self) -> bool

Source

pub fn is_bool(self) -> bool

Source

pub fn is_key(self) -> bool

Source

pub fn is_string(self) -> bool

Source

pub fn is_indirect_int(self) -> bool

Source

pub fn is_indirect_uint(self) -> bool

Source

pub fn is_indirect_float(self) -> bool

Source

pub fn is_map(self) -> bool

Source

pub fn is_heterogenous_vector(self) -> bool

Source

pub fn is_vector_int(self) -> bool

Source

pub fn is_vector_uint(self) -> bool

Source

pub fn is_vector_float(self) -> bool

Source

pub fn is_vector_key(self) -> bool

Source

pub fn is_vector_bool(self) -> bool

Source

pub fn is_vector_int2(self) -> bool

Source

pub fn is_vector_uint2(self) -> bool

Source

pub fn is_vector_float2(self) -> bool

Source

pub fn is_vector_int3(self) -> bool

Source

pub fn is_vector_uint3(self) -> bool

Source

pub fn is_vector_float3(self) -> bool

Source

pub fn is_vector_int4(self) -> bool

Source

pub fn is_vector_uint4(self) -> bool

Source

pub fn is_vector_float4(self) -> bool

Source

pub fn is_blob(self) -> bool

Trait Implementations§

Source§

impl Clone for FlexBufferType

Source§

fn clone(&self) -> FlexBufferType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FlexBufferType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FlexBufferType

Source§

fn default() -> FlexBufferType

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FlexBufferType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for FlexBufferType

Source§

fn eq(&self, other: &FlexBufferType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for FlexBufferType

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<u8> for FlexBufferType

Source§

type Error = TryFromPrimitiveError<FlexBufferType>

The type returned in the event of a conversion error.
Source§

fn try_from(number: u8) -> Result<Self, TryFromPrimitiveError<Self>>

Performs the conversion.
Source§

impl TryFromPrimitive for FlexBufferType

Source§

impl Copy for FlexBufferType

Source§

impl Eq for FlexBufferType

Source§

impl StructuralPartialEq for FlexBufferType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,