thrive_ipc/
api.rs

1extern crate libc;
2
3extern {
4    fn IPC_connect() -> libc::c_int;
5    fn IPC_bind(listen_port: libc::c_int) -> libc::c_int;
6    fn IPC_send(data: *mut libc::c_uchar,len: libc::c_int) -> libc::c_int;
7    fn IPC_receive(data: *mut libc::c_uchar,len: libc::c_int) -> libc::c_int;
8    fn IPC_close() -> libc::c_int;
9}
10
11pub fn connect() -> i32 {
12    unsafe {
13        IPC_connect()
14    }
15}
16
17pub fn bind(listen_port: i32) -> i32 {
18    unsafe {
19        IPC_bind(listen_port)
20    }
21}
22
23pub fn send(buf: &[u8], len: i32) -> i32 {
24    unsafe {
25        IPC_send(buf.as_ptr() as *mut u8,len)
26    }
27}
28
29pub fn receive(buf: &mut [u8], len: i32) -> i32 {
30    unsafe {
31        IPC_receive(buf.as_mut_ptr(),len)
32    }
33}
34
35pub fn close() -> i32 {
36    unsafe {
37        IPC_close()
38    }
39}