From e23661bac1a91dc71657befb82092154808ab5d1 Mon Sep 17 00:00:00 2001 From: Georgy Moshkin <gmoshkin@picodata.io> Date: Tue, 18 Oct 2022 16:26:20 +0300 Subject: [PATCH] feat: set_cfg_fields for multiple fields --- src/tarantool.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tarantool.rs b/src/tarantool.rs index 4dc880f785..2ab935796b 100644 --- a/src/tarantool.rs +++ b/src/tarantool.rs @@ -173,17 +173,25 @@ where cfg.into_get(field).ok() } +#[inline] pub fn set_cfg_field<T>(field: &str, value: T) -> Result<(), tlua::LuaError> where T: tlua::PushOneInto<tlua::LuaState>, tlua::Void: From<T::Err>, +{ + set_cfg_fields(((field, value),)) +} + +pub fn set_cfg_fields<T>(table: T) -> Result<(), tlua::LuaError> +where + tlua::AsTable<T>: tlua::PushInto<tlua::LuaState>, { use tlua::{Call, CallError}; let l = lua_state(); let b: LuaTable<_> = l.get("box").expect("can't fail under tarantool"); let cfg: tlua::Callable<_> = b.get("cfg").expect("can't fail under tarantool"); - cfg.call_with([(field, value)]).map_err(|e| match e { + cfg.call_with(tlua::AsTable(table)).map_err(|e| match e { CallError::PushError(_) => unreachable!("cannot fail during push"), CallError::LuaError(e) => e, }) -- GitLab