112 lines
2.9 KiB
Rust
112 lines
2.9 KiB
Rust
/* automatically generated by rust-bindgen 0.59.2 */
|
|
|
|
pub type size_t = ::std::os::raw::c_ulong;
|
|
pub type wchar_t = ::std::os::raw::c_uint;
|
|
#[repr(C)]
|
|
#[repr(align(16))]
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub struct max_align_t {
|
|
pub __clang_max_align_nonce1: ::std::os::raw::c_longlong,
|
|
pub __bindgen_padding_0: u64,
|
|
pub __clang_max_align_nonce2: u128,
|
|
}
|
|
#[test]
|
|
fn bindgen_test_layout_max_align_t() {
|
|
assert_eq!(
|
|
::std::mem::size_of::<max_align_t>(),
|
|
32usize,
|
|
concat!("Size of: ", stringify!(max_align_t))
|
|
);
|
|
assert_eq!(
|
|
::std::mem::align_of::<max_align_t>(),
|
|
16usize,
|
|
concat!("Alignment of ", stringify!(max_align_t))
|
|
);
|
|
assert_eq!(
|
|
unsafe {
|
|
&(*(::std::ptr::null::<max_align_t>())).__clang_max_align_nonce1 as *const _ as usize
|
|
},
|
|
0usize,
|
|
concat!(
|
|
"Offset of field: ",
|
|
stringify!(max_align_t),
|
|
"::",
|
|
stringify!(__clang_max_align_nonce1)
|
|
)
|
|
);
|
|
assert_eq!(
|
|
unsafe {
|
|
&(*(::std::ptr::null::<max_align_t>())).__clang_max_align_nonce2 as *const _ as usize
|
|
},
|
|
16usize,
|
|
concat!(
|
|
"Offset of field: ",
|
|
stringify!(max_align_t),
|
|
"::",
|
|
stringify!(__clang_max_align_nonce2)
|
|
)
|
|
);
|
|
}
|
|
#[repr(C)]
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub struct uws_app_s {
|
|
_unused: [u8; 0],
|
|
}
|
|
#[repr(C)]
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub struct uws_req_s {
|
|
_unused: [u8; 0],
|
|
}
|
|
#[repr(C)]
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub struct uws_res_s {
|
|
_unused: [u8; 0],
|
|
}
|
|
pub type uws_app_t = uws_app_s;
|
|
pub type uws_req_t = uws_req_s;
|
|
pub type uws_res_t = uws_res_s;
|
|
extern "C" {
|
|
pub fn uws_create_app() -> *mut uws_app_t;
|
|
}
|
|
extern "C" {
|
|
pub fn uws_app_get(
|
|
app: *mut uws_app_t,
|
|
pattern: *const ::std::os::raw::c_char,
|
|
handler: ::std::option::Option<
|
|
unsafe extern "C" fn(arg1: *mut uws_res_t,
|
|
arg2: *mut uws_req_t),
|
|
>,
|
|
);
|
|
}
|
|
extern "C" {
|
|
pub fn uws_app_run(arg1: *mut uws_app_t);
|
|
}
|
|
extern "C" {
|
|
pub fn uws_app_listen(
|
|
app: *mut uws_app_t,
|
|
port: ::std::os::raw::c_int,
|
|
handler: ::std::option::Option<unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void)>,
|
|
);
|
|
}
|
|
extern "C" {
|
|
pub fn uws_res_end(res: *mut uws_res_t, data: *const ::std::os::raw::c_char, length: size_t);
|
|
}
|
|
|
|
extern "C" fn listen_handler(listen_socket: *mut ::std::os::raw::c_void) {
|
|
println!("Listening");
|
|
}
|
|
|
|
extern "C" fn get_handler(res: *mut uws_res_t, req: *mut uws_req_t) {
|
|
unsafe {
|
|
uws_res_end(res, "Hello!".as_bytes().as_ptr(), 6);
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
unsafe {
|
|
let app = uws_create_app();
|
|
uws_app_get(app, ::std::ffi::CString::new("/*").expect("").as_ptr(), ::std::option::Option::Some(get_handler));
|
|
uws_app_listen(app, 3000, ::std::option::Option::Some(listen_handler));
|
|
uws_app_run(app);
|
|
}
|
|
} |