Struct tarantool::proc::ReturnMsgpack
source · pub struct ReturnMsgpack<T>(pub T);
Expand description
A wrapper type for returning custom types from stored procedures. Consider
using the custom_ret
attribute parameter instead (see tarantool::proc
docs for examples).
using ReturnMsgpack
directly
You can either return ReturnMsgpack
directly:
use tarantool::proc::ReturnMsgpack;
#[tarantool::proc]
fn foo(x: i32) -> ReturnMsgpack<MyStruct> {
ReturnMsgpack(MyStruct { x, y: x * 2 })
}
#[derive(serde::Serialize)]
struct MyStruct { x: i32, y: i32 }
implementing Return
for custom type
Or you can use it to implement Return
for your custom type:
use std::os::raw::c_int;
use tarantool::{proc::{Return, ReturnMsgpack}, tuple::FunctionCtx};
#[tarantool::proc]
fn foo(x: i32) -> MyStruct {
MyStruct { x, y: x * 2 }
}
#[derive(serde::Serialize)]
struct MyStruct { x: i32, y: i32 }
impl Return for MyStruct {
fn ret(self, ctx: FunctionCtx) -> c_int {
ReturnMsgpack(self).ret(ctx)
}
}
Tuple Fields§
§0: T
Trait Implementations§
source§impl<T: Serialize> Return for ReturnMsgpack<T>
impl<T: Serialize> Return for ReturnMsgpack<T>
fn ret(self, ctx: FunctionCtx) -> c_int
Auto Trait Implementations§
impl<T> RefUnwindSafe for ReturnMsgpack<T>where T: RefUnwindSafe,
impl<T> Send for ReturnMsgpack<T>where T: Send,
impl<T> Sync for ReturnMsgpack<T>where T: Sync,
impl<T> Unpin for ReturnMsgpack<T>where T: Unpin,
impl<T> UnwindSafe for ReturnMsgpack<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more