[][src]Enum flexbuffers::FlexBufferType

#[repr(u8)]pub enum FlexBufferType {
    Null,
    Int,
    UInt,
    Float,
    Bool,
    Key,
    String,
    IndirectInt,
    IndirectUInt,
    IndirectFloat,
    Map,
    Vector,
    VectorInt,
    VectorUInt,
    VectorFloat,
    VectorKey,
    VectorString,
    VectorBool,
    VectorInt2,
    VectorUInt2,
    VectorFloat2,
    VectorInt3,
    VectorUInt3,
    VectorFloat3,
    VectorInt4,
    VectorUInt4,
    VectorFloat4,
    Blob,
}

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

Nulls are represented with () in Rust.

Int

Variable width signed integer: i8, i16, i32, i64

UInt

Variable width unsigned integer: u8, u16, u32, u64

Float

Variable width floating point: f32, f64

Bool
Key

Null termintated, utf8 string. Typically used with Maps.

String

Stored with a unsigned integer length, then UTF-8 bytes, and an extra null terminator that is not counted with the length.

IndirectInt

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

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

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

Maps are like Vectors except elements are associated with, and sorted by, keys.

Vector

Heterogenous Vector (stored with a type table).

VectorInt

Homogenous Vector of Ints.

VectorUInt

Homogenous Vector of UInts.

VectorFloat

Homogenous Vector of Floats.

VectorKey

Homogenous Vector of Keys.

VectorString
Deprecated:

Please use Vector or VectorKey instead. See https://github.com/google/flatbuffers/issues/5627

Homogenous Vector of Strings.

VectorBool

Since the elements of a vector use the same BitWidth as the length, Blob is more efficient for >255 element boolean vectors.

VectorInt2

Homogenous vector of two Ints

VectorUInt2

Homogenous vector of two UInts

VectorFloat2

Homogenous vector of two Floats

VectorInt3

Homogenous vector of three Ints

VectorUInt3

Homogenous vector of three UInts

VectorFloat3

Homogenous vector of three Floats

VectorInt4

Homogenous vector of four Ints

VectorUInt4

Homogenous vector of four UInts

VectorFloat4

Homogenous vector of four Floats

Blob

An array of bytes. Stored with a variable width length.

Implementations

impl FlexBufferType[src]

pub fn is_inline(self) -> bool[src]

Returns true for flexbuffer types that are stored inline.

pub fn is_reference(self) -> bool[src]

Returns true for flexbuffer types that are stored by offset.

pub fn is_vector(self) -> bool[src]

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

pub fn has_length_slot(self) -> bool[src]

True iff the binary format stores the length. This applies to Blob, String, Maps, and Vectors of variable length.

pub fn is_fixed_length_vector(self) -> bool[src]

Returns true if called on a fixed length typed vector.

pub fn typed_vector_type(self) -> Option<FlexBufferType>[src]

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

pub fn fixed_length_vector_length(self) -> Option<usize>[src]

Return the length of the fixed length vector or None.

pub fn is_heterogenous(self) -> bool[src]

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

pub fn to_direct(self) -> Option<Self>[src]

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

pub fn is_null(self) -> bool[src]

pub fn is_int(self) -> bool[src]

pub fn is_uint(self) -> bool[src]

pub fn is_float(self) -> bool[src]

pub fn is_bool(self) -> bool[src]

pub fn is_key(self) -> bool[src]

pub fn is_string(self) -> bool[src]

pub fn is_indirect_int(self) -> bool[src]

pub fn is_indirect_uint(self) -> bool[src]

pub fn is_indirect_float(self) -> bool[src]

pub fn is_map(self) -> bool[src]

pub fn is_heterogenous_vector(self) -> bool[src]

pub fn is_vector_int(self) -> bool[src]

pub fn is_vector_uint(self) -> bool[src]

pub fn is_vector_float(self) -> bool[src]

pub fn is_vector_key(self) -> bool[src]

pub fn is_vector_string(self) -> bool[src]

pub fn is_vector_bool(self) -> bool[src]

pub fn is_vector_int2(self) -> bool[src]

pub fn is_vector_uint2(self) -> bool[src]

pub fn is_vector_float2(self) -> bool[src]

pub fn is_vector_int3(self) -> bool[src]

pub fn is_vector_uint3(self) -> bool[src]

pub fn is_vector_float3(self) -> bool[src]

pub fn is_vector_int4(self) -> bool[src]

pub fn is_vector_uint4(self) -> bool[src]

pub fn is_vector_float4(self) -> bool[src]

pub fn is_blob(self) -> bool[src]

Trait Implementations

impl Clone for FlexBufferType[src]

impl Copy for FlexBufferType[src]

impl Debug for FlexBufferType[src]

impl Default for FlexBufferType[src]

impl<'de> Deserialize<'de> for FlexBufferType[src]

impl Eq for FlexBufferType[src]

impl PartialEq<FlexBufferType> for FlexBufferType[src]

impl Serialize for FlexBufferType[src]

impl StructuralEq for FlexBufferType[src]

impl StructuralPartialEq for FlexBufferType[src]

impl TryFrom<u8> for FlexBufferType[src]

type Error = TryFromPrimitiveError<Self>

The type returned in the event of a conversion error.

impl TryFromPrimitive for FlexBufferType[src]

type Primitive = u8

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.