stringleton_registry/lib.rs
1//! Registry helper crate for `stringleton`
2//!
3//! You probably don't need to use this crate directly. Use the
4//! [`stringleton`](../stringleton) crate or the
5//! [`stringleton-dylib`](../stringleton-dylib) crate instead.
6//!
7//! This crate exists to support both static and dynamic linking when using
8//! `stringleton`.
9//!
10//! All binaries in a process must use the same symbol registry, so when a
11//! dynamic library (`dylib`) dependency is using `stringleton`, this crate must
12//! also be compiled as a dynamic library, which is ensured by the [linkage
13//! rules](https://doc.rust-lang.org/reference/linkage.html).
14//!
15//! This only works automatically when such a dependency is "implicitly" linked
16//! (i.e. it is a direct dependency in `Cargo.toml`). If dynamic libraries are
17//! being loaded at runtime by the host process, Cargo must be instructed to
18//! dynamically link against the registry, which can be achieved by using the
19//! `stringleton-dylib` crate in the main binary instead of `stringleton`.
20//!
21//! Note that if a dependency is a `cdylib` (crate-type), that dependency must
22//! explicitly link against `stringleton-dylib` for this trick to work. This is
23//! not necessary when building a normal Rust `dylib`.
24
25#![no_std]
26
27#[cfg(feature = "std")]
28extern crate std;
29
30#[cfg(any(feature = "std", feature = "alloc"))]
31extern crate alloc;
32
33mod registry;
34mod site;
35mod static_symbol;
36mod symbol;
37
38pub use registry::*;
39pub use site::*;
40pub use static_symbol::*;
41pub use symbol::*;