Crate diplomat_runtime

Crate diplomat_runtime 

Source
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§

DiplomatCallback
Struct representing a callback from Rust into a foreign language
DiplomatOwnedSlice
This is equivalent to Box<[T]>.
DiplomatOwnedUTF8StrSlice
This is equivalent to Box<str>, except it has a stable repr(C) layout
DiplomatResult
A Result-like type that can be passed across the FFI boundary as a value. Used internally to return Results and Options from functions.
DiplomatSlice
This is equivalent to &[T], except it has a stable repr(C) layout
DiplomatSliceMut
This is equivalent to &mut [T], except it has a stable repr(C) layout
DiplomatUtf8StrSlice
This is equivalent to &str, except it has a stable repr(C) layout
DiplomatWrite
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 DiplomatWrite that 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§

DiplomatByte
Like u8, but interpreted explicitly as a raw byte as opposed to a numerical value.
DiplomatChar
Like char, but unvalidated.
DiplomatOption
A type to represent Option over FFI.
DiplomatOwnedStr16Slice
An unvalidated, owned UTF-16 string that is safe to use over FFI
DiplomatOwnedStrSlice
This like Box<str>, but unvalidated and safe to use over FFI
DiplomatStr
Like str, but unvalidated.
DiplomatStr16
Like Wstr, but unvalidated.
DiplomatStr16Slice
An unvalidated UTF-16 string that is safe to use over FFI
DiplomatStrSlice
This like &str, but unvalidated and safe to use over FFI