low-luajit 0.2.0

Low level but safe bindings to the LuaJIT C API with no dependencies and no-std support to create Lua modules using Rust.
Documentation
use core::{ffi::CStr, marker::PhantomData, mem::MaybeUninit};
use crate::{LuaState, ffi};

// Currently disabled due to how hard it is to get LUAL_BUFFERSIZE for every target,
// paired with how I don't think this struct will be in high demand? If anyone asks for it I'll probably do it right away...
// If so, should I keep just brute forcing LUAL_BUFFERSIZE for every (officially supported) target I can think of,
// or just be way more hacky and reimplement most of the luaL_Buffer myself?

#[repr(transparent)]
#[derive(Debug)]
pub struct StringBuffer<'a>(*mut ffi::luaL_Buffer, PhantomData<&'a mut LuaState>);

/// [`StringBuffer`] related functions.
impl LuaState {
	pub fn init_buffer(&mut self) -> StringBuffer<'_> {
		if ffi::LUAL_BUFFERSIZE == 1 {
			panic!("Your target does not currently support `StringBuffer`!\nIf your target is officially supported by LuaJIT, contact me!");
		}

		unsafe {
			let mut buffer = MaybeUninit::<StringBuffer>::uninit();
			ffi::luaL_buffinit(self.0, buffer.as_mut_ptr().cast());
			buffer.assume_init()
		}
	}
}

impl StringBuffer<'_> {
	pub fn add_cstring(&mut self, cstring: &CStr) {
		unsafe { ffi::luaL_addstring(self.0, cstring.as_ptr()); }
	}

	pub fn push_result(self) {
		unsafe { ffi::luaL_pushresult(self.0); }
	}
}