53 lines
1.2 KiB
Rust
Raw Normal View History

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)]
#![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 {
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" {
#[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;
#[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
}
}