chromium/lib.rs
1#![no_std]
2#![warn(missing_docs)]
3
4//! Chromium helps add some stability to your metal.
5//!
6//! Specifically, this crate lets you turn select `repr(Rust)` types into a
7//! `repr(C)` struct that holds all the data necessary to safely reconstruct the
8//! original `repr(Rust)` form.
9//!
10//! This is primarily of use for sending data from Rust code on one side of a C
11//! ABI "FFI" call to other Rust code on the far side of that FFI call. Even if
12//! the Rust form of the data changes between compiler versions, because the C
13//! ABI is stable each side will be able to turn the information back into
14//! whatever it locally needs.
15//!
16//! You could of course also use this to communicate with non-Rust code if you
17//! need to.
18//!
19//! The types here provide fairly _minimal_ functionality beyond just turning
20//! themselves back into their `repr(Rust)` forms. A few basics like `Debug` and
21//! `Deref` and so on are provided as appropriate, but for any serious usage
22//! you're expected to just change the value back into the Rust form and use the
23//! "real" form of the data.
24//!
25//! ## Features
26//!
27//! * `unsafe_alloc` enables support for `Vec`, `String`, and `Box`.
28//! * Note that in this case you **must not** transfer allocations between two
29//! different global allocators.
30//! * As of 2020-03-06 it _happens to be the case_ that the default global
31//! allocators for Windows / Mac / Linux are process wide allocators. If you
32//! change the global allocator things can break. If the rust standard
33//! library changes their global allocator things can break.
34//! * This is a _brittle_ feature, not to be used lightly. That's why it says
35//! "unsafe" right in the feature name.
36
37#[cfg(feature = "unsafe_alloc")]
38extern crate alloc;
39
40mod stable_layout;
41pub use stable_layout::*;
42
43mod shared_slice;
44pub use shared_slice::*;
45
46mod unique_slice;
47pub use unique_slice::*;
48
49mod shared_str;
50pub use shared_str::*;
51
52mod unique_str;
53pub use unique_str::*;
54
55#[cfg(feature = "unsafe_alloc")]
56mod stable_vec;
57#[cfg(feature = "unsafe_alloc")]
58pub use stable_vec::*;
59
60#[cfg(feature = "unsafe_alloc")]
61mod stable_string;
62#[cfg(feature = "unsafe_alloc")]
63pub use stable_string::*;