Skip to content
Snippets Groups Projects
Commit a78015c2 authored by Yaroslav Dynnikov's avatar Yaroslav Dynnikov
Browse files

Add draft of tarantool module

parent 418c2f22
No related branches found
No related tags found
No related merge requests found
use std::os::raw::c_int;
mod tarantool;
#[no_mangle]
pub extern "C" fn luaopen_picolib(_l: std::ffi::c_void) -> c_int {
println!("Hello from rust lib");
for (key, value) in std::env::vars() {
if key.starts_with("PICODATA_") {
println!("{}: {}", key, value);
}
}
println!();
println!("Hello from Rust {}", std::module_path!());
println!(
"Running on {} {}",
tarantool::package(),
tarantool::version()
);
0
}
use std::ffi::CStr;
mod ffi {
use libc::c_char;
extern "C" {
pub fn tarantool_version() -> *const c_char;
pub fn tarantool_package() -> *const c_char;
}
}
pub fn version() -> &'static str {
let c_ptr = unsafe { ffi::tarantool_version() };
let c_str = unsafe { CStr::from_ptr(c_ptr) };
return c_str.to_str().unwrap();
}
pub fn package() -> &'static str {
let c_ptr = unsafe { ffi::tarantool_package() };
let c_str = unsafe { CStr::from_ptr(c_ptr) };
return c_str.to_str().unwrap();
}
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