1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! The [Diplomat](https://rust-diplomat.github.io/diplomat/) runtime crate.
//!
//! This crate provides Diplomat-specific types for crates writing `#[diplomat::bridge]` modules.
//! Include this in any crate that also depends on `diplomat`, since `#[diplomat::bridge]`
//! will generate code that relies on types from here.
//!
//! This crate contains a fair number of `DiplomatFoo` types. Some, like
//! [`DiplomatOption`], are FFI-safe versions of Rust types that can be put in
//! a struct and passed safely over FFI. Others, like [`DiplomatChar`], are simple
//! type aliases that signal to the Diplomat tool that particular semantics are desired
//! on the C++ side.
//!
//! # Features
//!
//! The `log` feature enables logging support, currently enabled via the wasm-only `diplomat_init()`.
//!
//! The `jvm-callback-support` feature should be enabled if building Diplomat for use in the JVM, for
//! a Diplomat-based library that uses callbacks.
extern crate alloc;
use Layout;
pub use DiplomatWrite;
pub use ;
pub use ;
pub use DiplomatCallback;
pub use ;
/// Like [`char`], but unvalidated.
///
/// This type will usually map to some character type in the target language, and
/// you will not need to worry about the safety of mismatched string invariants.
pub type DiplomatChar = u32;
/// Like [`str`], but unvalidated.
///
/// This is a dynamically sized type, it should be used behind an `&` or a `Box<T>`
///
/// This type will usually map to some string type in the target language, and
/// you will not need to worry about the safety of mismatched string invariants.
pub type DiplomatStr = ;
/// Like `Wstr`, but unvalidated.
///
/// This is a dynamically sized type, it should be used behind an `&` or a `Box<T>`
///
/// This type will usually map to some string type in the target language, and
/// you will not need to worry about the safety of mismatched string invariants.
pub type DiplomatStr16 = ;
/// Like [`u8`], but interpreted explicitly as a raw byte as opposed to a numerical value.
///
/// This matters for languages like JavaScript or Dart, where there's only a single numeric
/// type, but special types for byte buffers.
pub type DiplomatByte = u8;
/// Allocates a buffer of a given size in Rust's memory.
///
/// Primarily to be called by generated FFI bindings, not Rust code, but is available if needed.
///
/// # Safety
/// - The allocated buffer must be freed with [`diplomat_free()`].
pub unsafe extern "C"
/// Frees a buffer that was allocated in Rust's memory.
///
/// Primarily to be called by generated FFI bindings, not Rust code, but is available if needed.
///
/// # Safety
/// - `ptr` must be a pointer to a valid buffer allocated by [`diplomat_alloc()`].
pub unsafe extern "C"
/// Whether a `&[u8]` is a `&str`.
///
/// Primarily to be called by generated FFI bindings, not Rust code, but is available if needed.
///
/// # Safety
/// - `ptr` and `size` must be a valid `&[u8]`
pub unsafe extern "C"