Expand description
A crate that provides abi-safe and stable wrappers of language and library constructs that don’t have fixed abi This provides shims for otherwise unusable constructs that can validly be passed accross ABI bounderies. All publically exposed types in this api have a stable layout and abi, that may only change on semver major versions Thus, it is valid to use these types accross versions
§Interface
This crate relies on a number of special symbols, provided by an interface library, which is typically a cdylib (so that there is one copy at runtime).
This interface is typically provided by the xlang_interface crate (which is linked by using the xlang crate), otherwise, it must be provided and linked separately.
The symbols that this crate expects the interface library to provide are considered unstable, but all start with either the xlang_ or XLANG_ prefix.
The symbols are publically available in the module that makes primary of them.
The current list is:
Modules§
- alloc
- ABI Safe Interface for allocation. Also provides allocator functions that can be used accross modules (on windows, the system allocator cannot be safely used to do so)
- boxed
- Implementation of
std::boxed::Boxthat uses thealloc::Allocatortrait, and is ABI safe for all allocators - collection
- Implementation of various collections that use the
alloc::Allocatortrait and that have Stable ABI - hash
- Defines Hashers for xlang that perform consistent operations
- io
- Defines io traits and types that are ABI Safe and can be used with
traits::DynRef(et. al) - ops
- Try stuff
- option
- Defines an ABI safe equivalent for
std::option::Optionfor all types. - pair
- Defines a Pair type, which is an ABI safe two-tuple
- prelude
- prelude for
xlang_abi - primitives
- Primitive types defined by the OS (such as the size type and the pointer-sized type).
- ptr
- Defines pointer types and interfaces that are abi safe.
- result
- Defines an ABI safe equivalent to
std::result::Result. - span
- Defines ABI safe equivalents for
&[T]and&mut [T] - string
- Implementation of
std::string::Stringthat usesalloc::Allocator, and is ABI safe. Also defines an ABI safe equivalent for&str(but not&mut str) - traits
- Defines an ABI safe interface for trait objects, by emulating the vtable and fat pointer
- vec
- Implementation of
std::string::Stringthat usesalloc::Allocator, and is ABI safe.
Macros§
- const_
sv - Constructs a
StringViewin a constant context. This is equivalent toStringView::new(str), except it is valid in a const initializer - format
- Version of
std::formatthat returns aString - rustcall
- A macro which allows definining functions, function pointer types, and extern blocks using the
"rustcall"abi. This abi matches the ABI used by lcrust v0 forextern "Rust"functions, without#[track_caller]support. See The LCRust v0 ABI for details on the interface. - set
- Creates a
HashSetfrom given elements, discarding duplicates - span
- Produces an immutable span over a static (promoted) array of constant exressions
- try_
?operator forxlang_abitypes- vec
- Constructs a new
veccontaining the given elements.