1#![allow(non_camel_case_types)]
2#![allow(non_snake_case)]
3#![allow(non_upper_case_globals)]
4#![allow(clippy::all)]
5#![allow(rustdoc::all)]
6
7mod bindings;
8
9use std::ops::Deref;
10
11pub use bindings::*;
12
13#[macro_export]
15macro_rules! sized {
16 ($ty:ty) => {{
17 let mut t = <$ty as ::std::default::Default>::default();
18 t.size = ::std::mem::size_of::<$ty>();
19 t
20 }};
21}
22
23impl<S> From<S> for bindings::String
24where
25 S: Deref<Target = str>,
26{
27 fn from(value: S) -> Self {
28 Self {
29 ptr: value.as_ptr(),
30 len: value.len(),
31 }
32 }
33}
34
35impl bindings::String {
36 pub unsafe fn to_str<'a>(self) -> &'a str {
42 let slice = unsafe { std::slice::from_raw_parts(self.ptr, self.len) };
44 unsafe { std::str::from_utf8_unchecked(slice) }
45 }
46}