Expand description
The 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.
Modules§
- rust_
interop - Types for interfacing with Diplomat FFI APIs from Rust.
Structs§
- Diplomat
Callback - Struct representing a callback from Rust into a foreign language
- Diplomat
Owned Slice - This is equivalent to
Box<[T]>. - Diplomat
OwnedUT F8Str Slice - This is equivalent to
Box<str>, except it has a stablerepr(C)layout - Diplomat
Result - A
Result-like type that can be passed across the FFI boundary as a value. Used internally to returnResults andOptions from functions. - Diplomat
Slice - This is equivalent to
&[T], except it has a stablerepr(C)layout - Diplomat
Slice Mut - This is equivalent to
&mut [T], except it has a stable repr(C) layout - Diplomat
Utf8 StrSlice - This is equivalent to
&str, except it has a stablerepr(C)layout - Diplomat
Write - An object that can one can write UTF-8 strings to
Functions§
- diplomat_
alloc ⚠ - Allocates a buffer of a given size in Rust’s memory.
- diplomat_
buffer_ write_ create - Create an
DiplomatWritethat can write to a dynamically allocated buffer managed by Rust. - diplomat_
buffer_ ⚠write_ destroy - Destructor for Rust-memory backed writables.
- diplomat_
free ⚠ - Frees a buffer that was allocated in Rust’s memory.
- diplomat_
is_ ⚠str - Whether a
&[u8]is a&str.
Type Aliases§
- Diplomat
Byte - Like
u8, but interpreted explicitly as a raw byte as opposed to a numerical value. - Diplomat
Char - Like
char, but unvalidated. - Diplomat
Option - A type to represent Option
over FFI. - Diplomat
Owned Str16 Slice - An unvalidated, owned UTF-16 string that is safe to use over FFI
- Diplomat
Owned StrSlice - This like
Box<str>, but unvalidated and safe to use over FFI - Diplomat
Str - Like
str, but unvalidated. - Diplomat
Str16 - Like
Wstr, but unvalidated. - Diplomat
Str16 Slice - An unvalidated UTF-16 string that is safe to use over FFI
- Diplomat
StrSlice - This like
&str, but unvalidated and safe to use over FFI