pub struct Tuple { /* private fields */ }
Expand description
Tuple
Implementations§
Source§impl Tuple
impl Tuple
Sourcepub fn from_struct<T>(value: &T) -> Result<Self, Error>where
T: AsTuple,
pub fn from_struct<T>(value: &T) -> Result<Self, Error>where
T: AsTuple,
Creates new tuple from value
.
This function will serialize structure instance value
of type T
into tuple internal representation
See also: AsTuple
Sourcepub fn bsize(&self) -> usize
pub fn bsize(&self) -> usize
Will return the number of bytes in the tuple.
With both the memtx storage engine and the vinyl storage engine the default maximum is one megabyte
(memtx_max_tuple_size
or vinyl_max_tuple_size
). Every field has one or more “length” bytes preceding the
actual contents, so bsize()
returns a value which is slightly greater than the sum of the lengths of the
contents.
The value does not include the size of “struct tuple” (for the current size of this structure look in the tuple.h file in Tarantool’s source code).
Sourcepub fn format(&self) -> TupleFormat
pub fn format(&self) -> TupleFormat
Return the associated format.
Sourcepub fn iter(&self) -> Result<TupleIterator, Error>
pub fn iter(&self) -> Result<TupleIterator, Error>
Allocate and initialize a new Tuple
iterator. The Tuple
iterator
allow to iterate over fields at root level of MsgPack array.
Example:
let mut it = tuple.iter().unwrap();
while let Some(field) = it.next().unwrap() {
// process data
}
// rewind iterator to first position
it.rewind();
assert!(it.position() == 0);
// rewind iterator to first position
field = it.seek(3).unwrap();
assert!(it.position() == 4);
Sourcepub fn field<T>(&self, fieldno: u32) -> Result<Option<T>, Error>where
T: DeserializeOwned,
pub fn field<T>(&self, fieldno: u32) -> Result<Option<T>, Error>where
T: DeserializeOwned,
Return the raw Tuple field in MsgPack format.
The buffer is valid until next call to box_tuple_* functions.
fieldno
- zero-based index in MsgPack array.
Returns:
None
ifi >= box_tuple_field_count(Tuple)
or if field has a non primitive type- field value otherwise
Sourcepub fn into_struct<T>(self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn into_struct<T>(self) -> Result<T, Error>where
T: DeserializeOwned,
Deserializes tuple contents into structure of type T