2023-05-30 22:23:11 -07:00
|
|
|
#![allow(clippy::missing_safety_doc)]
|
2022-07-05 21:13:09 -07:00
|
|
|
#![feature(format_args_nl)]
|
2023-05-25 23:45:38 -07:00
|
|
|
#![feature(io_error_more)]
|
2022-07-05 21:13:09 -07:00
|
|
|
|
2022-08-08 22:53:37 -07:00
|
|
|
pub use libc;
|
2022-08-19 02:21:52 -07:00
|
|
|
|
2023-06-09 02:00:37 -07:00
|
|
|
use cxx_extern::*;
|
2022-09-15 01:17:05 -07:00
|
|
|
pub use files::*;
|
2022-07-01 04:53:41 -07:00
|
|
|
pub use logging::*;
|
2022-07-05 21:13:09 -07:00
|
|
|
pub use misc::*;
|
2022-07-01 04:53:41 -07:00
|
|
|
|
2023-06-09 02:00:37 -07:00
|
|
|
mod cxx_extern;
|
2022-09-15 01:17:05 -07:00
|
|
|
mod files;
|
2022-07-01 04:53:41 -07:00
|
|
|
mod logging;
|
2022-07-05 21:13:09 -07:00
|
|
|
mod misc;
|
2022-08-08 22:53:37 -07:00
|
|
|
mod xwrap;
|
2022-07-01 04:53:41 -07:00
|
|
|
|
|
|
|
#[cxx::bridge]
|
|
|
|
pub mod ffi {
|
2022-07-06 01:16:08 -07:00
|
|
|
#[derive(Copy, Clone)]
|
2022-07-01 04:53:41 -07:00
|
|
|
pub enum LogLevel {
|
2023-06-29 16:44:44 -07:00
|
|
|
ErrorCxx,
|
2022-07-01 04:53:41 -07:00
|
|
|
Error,
|
|
|
|
Warn,
|
|
|
|
Info,
|
|
|
|
Debug,
|
|
|
|
}
|
|
|
|
|
2023-06-20 18:17:26 -07:00
|
|
|
unsafe extern "C++" {
|
|
|
|
include!("misc.hpp");
|
|
|
|
fn mut_u8_patch(buf: &mut [u8], from: &[u8], to: &[u8]) -> Vec<usize>;
|
|
|
|
}
|
|
|
|
|
2022-07-01 04:53:41 -07:00
|
|
|
extern "Rust" {
|
2023-06-29 16:44:44 -07:00
|
|
|
#[rust_name = "log_from_cxx"]
|
2023-05-09 19:14:08 -07:00
|
|
|
fn log_with_rs(level: LogLevel, msg: &[u8]);
|
2022-07-01 04:53:41 -07:00
|
|
|
fn exit_on_error(b: bool);
|
2022-07-06 01:16:08 -07:00
|
|
|
fn set_log_level_state(level: LogLevel, enabled: bool);
|
|
|
|
fn cmdline_logging();
|
2022-07-01 04:53:41 -07:00
|
|
|
}
|
2022-08-19 02:21:52 -07:00
|
|
|
|
2023-05-16 02:09:05 -07:00
|
|
|
#[namespace = "rust"]
|
2022-08-19 02:21:52 -07:00
|
|
|
extern "Rust" {
|
|
|
|
fn xpipe2(fds: &mut [i32; 2], flags: i32) -> i32;
|
2023-06-09 02:00:37 -07:00
|
|
|
#[rust_name = "fd_path_for_cxx"]
|
2022-09-15 01:17:05 -07:00
|
|
|
fn fd_path(fd: i32, buf: &mut [u8]) -> isize;
|
2023-06-12 01:07:43 -07:00
|
|
|
#[rust_name = "map_file_for_cxx"]
|
|
|
|
fn map_file(path: &[u8], rw: bool) -> &'static mut [u8];
|
|
|
|
#[rust_name = "map_fd_for_cxx"]
|
|
|
|
fn map_fd(fd: i32, sz: usize, rw: bool) -> &'static mut [u8];
|
2022-08-19 02:21:52 -07:00
|
|
|
}
|
|
|
|
}
|