We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add derive macros for some commonly used trails like FromObject
FromObject
Where set_emap is the function that I expose to the user lua user, wishing to receive the string or table type of the lua
set_emap
string
table
fn set_emap( mode: Mode, lhs: , rhs: , opts: , ) -> oxi::Result<()> { //TODO } #[derive(FromObject)] enum Mode { ByString(String) ByTable(Dictionary) }
The text was updated successfully, but these errors were encountered:
Yea, derive macros would be great! In the meantime, I use this.
#[macro_export] macro_rules! lua_interop { ($type:ty) => { impl nvim_oxi::conversion::FromObject for $type { fn from_object(object: nvim_oxi::Object) -> Result<Self, nvim_oxi::conversion::Error> { use nvim_oxi::serde::Deserializer; use serde::Deserialize; Self::deserialize(Deserializer::new(object)).map_err(Into::into) } } impl nvim_oxi::conversion::ToObject for $type { fn to_object(self) -> Result<nvim_oxi::Object, nvim_oxi::conversion::Error> { use nvim_oxi::serde::Serializer; use serde::Serialize; self.serialize(Serializer::new()).map_err(Into::into) } } impl nvim_oxi::lua::Poppable for $type { unsafe fn pop( lstate: *mut nvim_oxi::lua::ffi::lua_State, ) -> Result<Self, nvim_oxi::lua::Error> { use nvim_oxi::{conversion::FromObject, Object}; let object = Object::pop(lstate)?; Self::from_object(object) .map_err(nvim_oxi::lua::Error::pop_error_from_err::<Self, _>) } } impl nvim_oxi::lua::Pushable for $type { unsafe fn push( self, lstate: *mut nvim_oxi::lua::ffi::lua_State, ) -> Result<std::ffi::c_int, nvim_oxi::lua::Error> { use nvim_oxi::conversion::ToObject; self.to_object() .map_err(nvim_oxi::lua::Error::push_error_from_err::<Self, _>)? .push(lstate) } } }; }
Sorry, something went wrong.
No branches or pull requests
Add derive macros for some commonly used trails like
FromObject
Where
set_emap
is the function that I expose to the user lua user, wishing to receive thestring
ortable
type of the luaThe text was updated successfully, but these errors were encountered: