pub struct Tuple { /* private fields */ }
Expand description
Tuple
Implementations
sourceimpl Tuple
impl Tuple
sourcepub fn from_struct<T>(value: &T) -> Result<Self> where
T: AsTuple,
pub fn from_struct<T>(value: &T) -> Result<Self> 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 unsafe fn from_raw_data(data: *mut c_char, len: u32) -> Self
pub unsafe fn from_raw_data(data: *mut c_char, len: u32) -> Self
Safety
data
must point to a buffer containing len
bytes representing a
valid messagepack array
sourcepub unsafe fn from_slice(data: &[u8]) -> Self
pub unsafe fn from_slice(data: &[u8]) -> Self
Safety
data
must represent a valid messagepack array
pub fn try_from_slice(data: &[u8]) -> Result<Self>
pub fn from_ptr(ptr: NonNull<BoxTuple>) -> Self
pub fn try_from_ptr(ptr: *mut BoxTuple) -> Option<Self>
pub fn is_empty(&self) -> bool
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>
pub fn iter(&self) -> Result<TupleIterator>
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::<T>().unwrap() {
// process data
}
// rewind iterator to first position
it.rewind();
assert!(it.position() == 0);
// rewind iterator to first position
let field = it.seek::<T>(3).unwrap();
assert!(it.position() == 4);
}
sourcepub fn field<'a, T>(&'a self, fieldno: u32) -> Result<Option<T>> where
T: Deserialize<'a>,
pub fn field<'a, T>(&'a self, fieldno: u32) -> Result<Option<T>> where
T: Deserialize<'a>,
Deserialize a tuple field specified by zero-based array index.
fieldno
- zero-based index in MsgPack array.
Returns:
Ok(None)
iffieldno >= self.len()
Err(e)
if deserialization failedOk(Some(field value))
otherwise
See also Tuple::try_get
, Tuple::get
.
sourcepub fn try_get<'a, I, T>(&'a self, key: I) -> Result<Option<T>> where
I: TupleIndex,
T: Deserialize<'a>,
pub fn try_get<'a, I, T>(&'a self, key: I) -> Result<Option<T>> where
I: TupleIndex,
T: Deserialize<'a>,
Deserialize a tuple field specified by an index implementing
TupleIndex
trait.
Currently 2 types of indexes are supported:
u32
- zero-based index in MsgPack array (See alsoTuple::field
)&str
- JSON path for tuples with non default formats
Returns:
Ok(None)
if index wasn’t foundErr(e)
if deserialization failedOk(Some(field value))
otherwise
See also Tuple::get
.
sourcepub fn get<'a, I, T>(&'a self, key: I) -> Option<T> where
I: TupleIndex,
T: Deserialize<'a>,
pub fn get<'a, I, T>(&'a self, key: I) -> Option<T> where
I: TupleIndex,
T: Deserialize<'a>,
Deserialize a tuple field specified by an index implementing
TupleIndex
trait.
Currently 2 types of indexes are supported:
u32
- zero-based index in MsgPack array (See alsoTuple::field
)&str
- JSON path for tuples with non default formats
Returns:
None
if index wasn’t found- panics if deserialization failed
Some(field value)
otherwise
See also Tuple::get
.
sourcepub fn as_struct<T>(&self) -> Result<T> where
T: DeserializeOwned,
pub fn as_struct<T>(&self) -> Result<T> where
T: DeserializeOwned,
Deserializes tuple contents into structure of type T
sourcepub fn into_struct<T>(self) -> Result<T> where
T: DeserializeOwned,
pub fn into_struct<T>(self) -> Result<T> where
T: DeserializeOwned,
Deserializes tuple contents into structure of type T
Trait Implementations
sourceimpl From<&'_ FunctionArgs> for Tuple
impl From<&'_ FunctionArgs> for Tuple
sourcefn from(args: &FunctionArgs) -> Tuple
fn from(args: &FunctionArgs) -> Tuple
Converts to this type from the input type.
sourceimpl From<&'_ TupleBuffer> for Tuple
impl From<&'_ TupleBuffer> for Tuple
sourcefn from(buf: &TupleBuffer) -> Self
fn from(buf: &TupleBuffer) -> Self
Converts to this type from the input type.
sourceimpl From<FunctionArgs> for Tuple
impl From<FunctionArgs> for Tuple
sourcefn from(args: FunctionArgs) -> Tuple
fn from(args: FunctionArgs) -> Tuple
Converts to this type from the input type.
sourceimpl From<Tuple> for TupleBuffer
impl From<Tuple> for TupleBuffer
sourceimpl<L> LuaRead<L> for Tuple where
L: AsLua,
impl<L> LuaRead<L> for Tuple where
L: AsLua,
sourcefn lua_read_at_position(lua: L, index: NonZeroI32) -> Result<Self, L>
fn lua_read_at_position(lua: L, index: NonZeroI32) -> Result<Self, L>
Reads the data from Lua at a given position.
fn n_values_expected() -> i32
fn lua_read_at_maybe_zero_position(lua: L, index: i32) -> Result<Self, L>
sourceimpl<L> Push<L> for Tuple where
L: AsLua,
impl<L> Push<L> for Tuple where
L: AsLua,
sourcefn push_to_lua(&self, lua: L) -> PushResult<L, Self>
fn push_to_lua(&self, lua: L) -> PushResult<L, Self>
Pushes the value on the top of the stack. Read more
impl<L> PushOne<L> for Tuple where
L: AsLua,
Auto Trait Implementations
impl RefUnwindSafe for Tuple
impl !Send for Tuple
impl !Sync for Tuple
impl Unpin for Tuple
impl UnwindSafe for Tuple
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more