rust_style/
lib.rs

1mod ffi {
2    extern "C" {
3        pub fn color(code: i32, back: bool) -> *const i8;
4        pub fn style(code: i32) -> *const i8;
5    }
6}
7
8pub fn get_color(code: i32, back: bool) -> &'static str {
9    unsafe {
10        let c_str = ffi::color(code, back);
11        std::ffi::CStr::from_ptr(c_str).to_str().unwrap()
12    }
13}
14
15pub fn get_style(code: i32) -> &'static str {
16    unsafe {
17        let c_str = ffi::style(code);
18        std::ffi::CStr::from_ptr(c_str).to_str().unwrap()
19    }
20}