Skip to content
Snippets Groups Projects
Commit e23661ba authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon: Committed by Georgy Moshkin
Browse files

feat: set_cfg_fields for multiple fields

parent 4cc2417d
No related branches found
No related tags found
1 merge request!299Feat/poor mans vshard
......@@ -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,
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment