Struct flatbuffers::Table
[−]
[src]
pub struct Table { /* fields omitted */ }
Table provides functions to read Flatbuffer data.
Methods
impl Table
[src]
fn from_offset(buffer: Rc<Vec<u8>>, pos: usize) -> Table
Create a table using from a slice using data starting at pos
.
First UOffsetT
should indicate the offset from the root
of the table to the begining of the object.
In the following example pos should be 0:
16, 0, 0, 0, // root of table: points to object <--------- 0, 0, // padding 10, 0, // vtable bytes 8, 0, // size of object 7, 0, // start of value 0 6, 0, // start of value 1 5, 0, // start of value 2 10, 0, 0, 0, // start of object..ie. vtable offset 0, // padding 77, // value 2 66, // value 1 55, // value 0
fn with_pos(buffer: Rc<Vec<u8>>, pos: usize) -> Table
Create a table for an object.
pos
should be the offset to the first byte of
useable data.
In the following example pos should be 16:
16, 0, 0, 0, // root of table: points to object 0, 0, // padding 10, 0, // vtable bytes 8, 0, // size of object 7, 0, // start of value 0 6, 0, // start of value 1 5, 0, // start of value 2 10, 0, 0, 0, // start of object..ie. vtable offset <--------- 0, // padding 77, // value 2 66, // value 1 55, // value 0
fn get_root(&self, offset: UOffsetT) -> Table
Return an object table at offset.
See from_offset
.
fn get_indirect_root(&self, offset: UOffsetT) -> Table
Return an object table at offset specified by offset.
fn field_offset(&self, field: VOffsetT) -> UOffsetT
Returns the field offset or 0 if the field was not present.
fn get_slot_bool(&self, slot: VOffsetT, default: bool) -> bool
Returns the bool
value of the field at the offset written in the
vtable slot
.
fn get_slot_u8(&self, slot: VOffsetT, default: u8) -> u8
Returns the u8
value of the field at the offset written in the
vtable slot
.
fn get_slot_i8(&self, slot: VOffsetT, default: i8) -> i8
Returns the i8
value of the field at the offset written in the
vtable slot
.
fn get_slot_u16(&self, slot: VOffsetT, default: u16) -> u16
Returns the u16
value of the field at the offset written in the
vtable slot
.
fn get_slot_i16(&self, slot: VOffsetT, default: i16) -> i16
Returns the i16
value of the field at the offset written in the
vtable slot
.
fn get_slot_u32(&self, slot: VOffsetT, default: u32) -> u32
Returns the u32
value of the field at the offset written in the
vtable slot
.
fn get_slot_i32(&self, slot: VOffsetT, default: i32) -> i32
Returns the i32
value of the field at the offset written in the
vtable slot
.
fn get_slot_u64(&self, slot: VOffsetT, default: u64) -> u64
Returns the u64
value of the field at the offset written in the
vtable slot
.
fn get_slot_i64(&self, slot: VOffsetT, default: i64) -> i64
Returns the i64
value of the field at the offset written in the
vtable slot
.
fn get_slot_f32(&self, slot: VOffsetT, default: f32) -> f32
Returns the f32
value of the field at the offset written in the
vtable slot
.
fn get_slot_f64(&self, slot: VOffsetT, default: f64) -> f64
Returns the f64
value of the field at the offset written in the
vtable slot
.
fn get_slot_str(&self, slot: VOffsetT) -> &str
Returns the &str
value of the field at the offset written in the
vtable slot
.
fn get_slot_struct<T: From<Table>>(&self, slot: VOffsetT) -> Option<T>
Returns the struct T
value of the field at the offset written in the
vtable slot
.
fn get_slot_vector<T>(&self, slot: VOffsetT) -> Iterator<T>
Returns the unsigned byte vector value of the field at the offset written in the
vtable slot
.
fn get_vector<T>(&self, offset: UOffsetT) -> Iterator<T>
ByteVector gets an unsigned byte slice from data stored inside the flatbuffer.
fn get_bool(&self, offset: UOffsetT) -> bool
Returns a value of bool
at offset
.
fn get_u8(&self, offset: UOffsetT) -> u8
Returns a value of u8
at offset
.
fn get_i8(&self, offset: UOffsetT) -> i8
Returns a value of i8
at offset
.
fn get_u16(&self, offset: UOffsetT) -> u16
Returns a value of u16
at offset
.
fn get_i16(&self, offset: UOffsetT) -> i16
Returns a value of i16
at offset
.
fn get_u32(&self, offset: UOffsetT) -> u32
Returns a value of u32
at offset
.
fn get_i32(&self, offset: UOffsetT) -> i32
Returns a value of i32
at offset
.
fn get_u64(&self, offset: UOffsetT) -> u64
Returns a value of u64
at offset
.
fn get_i64(&self, offset: UOffsetT) -> i64
Returns a value of i64
at offset
.
fn get_f32(&self, offset: UOffsetT) -> f32
Returns a value of f32
at offset
.
fn get_f64(&self, offset: UOffsetT) -> f64
Returns a value of f64
at offset
.
fn get_str(&self, offset: UOffsetT) -> &str
Returns a value of &str
at offset
.
fn get_struct<T: From<Table>>(&self, offset: UOffsetT) -> T
Retrieve a struct table from offset. Offset should point to then first usable byte of data i.e. the Vtable offset.
fn get_pos(&self) -> UOffsetT
Accesor function for the tables position in the buffer.
fn read_uoffset(&self, offset: UOffsetT) -> UOffsetT
Reads an UOffsetT
at exact position.
fn read_voffset(&self, offset: UOffsetT) -> VOffsetT
Reads an VOffsetT
at exact position.
fn read_voffset_slot(&self, slot: VOffsetT, d: VOffsetT) -> VOffsetT
Retrieves the VOffsetT
in the vtable slot
.
If the vtable value is zero, the default value d
will be returned.
fn get_bytes(&self) -> &[u8]
Get a reference to the raw buffer
Trait Implementations
impl Debug for Table
[src]
impl Clone for Table
[src]
fn clone(&self) -> Table
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Table
[src]
fn eq(&self, __arg_0: &Table) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Table) -> bool
This method tests for !=
.