Abi Stable Crates Versions Save

Rust-to-Rust ffi,ffi-safe equivalents of std types,and creating libraries loaded at startup.

v0.10.3

2 years ago

Fixed failed compilation in recent nightly(which required bumping the MSRV to 1.46.0, due to internal compiler errors in previous versions), includes a variety of additions, and a few deprecations.

Changelog

0.10.3

Bumped Minimum Supported Rust Version to 1.46.0 because fixing support for Rust nightly caused Internal Compiler Errors in older Rust versions.

Added StableAbi impls for f32 and f64.

Fixed error in StableAbi derive caused by using the derive inside a function with the proc_macro_derive_resolution_fallback lint enabled (deny-by-default in nightly).

Deprecated abi_stable::library::mangled_root_module_loader_name function.

Superceeded the mangled_root_module_loader_name function (and uses of it) with these abi_stable::library constants:

  • ROOT_MODULE_LOADER_NAME
  • ROOT_MODULE_LOADER_NAME_WITH_NUL
  • ROOT_MODULE_LOADER_NAME_NULSTR

Added NulStr::{as_ptr, try_from_str} associated functions.

Added ǸulStrError, returned by NulStr::try_from_str

Added PartialEq impls for comparing str and NulStr in both directions.

Added Default, PartialOrd, and Ord impls for NulStr.

Made NulStr::from_str safe, by not requiring no internal nul bytes.

Deprecated nul_str macro.

Added nulstr and nulstr_trunc macros.

Added "rust_latest_stable" feature.

Added LibHeader::ensure_layout method.

Fixed StaticRef::as_prefix doc example.

Added for_examples::PhantModule struct

Added RHashMap::{keys, values} methods for iterating over the map, which return the Keys and Values iterators respectively.

Added Index and IndexMut impls for RSliceMut and RVec

Added Index impl for RSlice

Changed these methods to use R: RangeBounds<usize> instead of [T]: Index<I, Output = [T]> or Index<I, Output = [T]>:

  • RVec::slice
  • RVec::slice_mut
  • RVec::drain

Replaced all Into implementations converting from abi_stable types with From impls converting in the same direction.

Rewrote staticref macro to support more cases of static promotion, this breaks non-inherent-impl uses of the macro(it was documented that this breaking change could happen).

Made libraries loaded with RootModule never be unloaded, previously they were unloaded when the type layout of the root module isn't compatible (this was possibly unsound?).

Formatted documentation examples (all doc examples up to sabi_types were formatted with rustfmt, every one from std_types up to the last module were manually formatted).

Added dependency on paste 1.0

Enabled the "macro_utils" feature of core_extensions

0.10.1

2 years ago

This release fixes many soundness issues (discovered using miri with the --Zmiri-track-raw-pointers flag), primarily changing trait objects from using & and &mut pointers to RRef and RMut for type erasure.

Changelog

0.10.1

Fixed support for building in ARM, from this pull request: https://github.com/rodrimati1992/abi_stable_crates/pull/50 (if this causes other problems with ARM please create an issue!)

0.10.0

Fixed soundness of the code under the Stacked Borrows model, by replacing uses of type-erased & and &muts in trait objects and vtables with RRef and RMut.

Added AsPtr and AsMutPtr traits. implemented for all erasable pointer types.

Reexported crate::erased_types::InterfaceBound in root module

Unimplemented Deref for RRef

Unimplemented Deref and DerefMut for RMut

Replaced all Deref and DerefMut bounds in trait object types with GetPointerKind/AsPtr/AsMutPtr.

Removed RRef::transmute which turns RRef<'a, T> into RRef<'b, U>

Renamed RRef:

  • get_raw: to as_ptr
  • transmute_ref: to transmute
  • cast_into_raw: to transmute_into_raw

Added these RRef methods:

  • get_copy
  • transmute_into_ref

Renamed RMut:

  • get: to into_ref,
  • get_mut: to into_mut,
  • into_raw: to into_raw_mut,
  • cast_into_raw: to transmute_into_raw,

Added these RMut methods:

  • get: this only borrows the RMut
  • get_copy: this only borrows the RMut
  • get_mut: this only borrows the RMut
  • as_ptr
  • as_mut_ptr
  • into_raw
  • transmute
  • transmute_into_raw
  • transmute_into_mut
  • as_rref

Added these functions to MovePtr:

  • from_raw
  • from_rmut
  • transmute

Changes to GetPointerKind:

  • Removed Deref supertrait
  • Added PtrTarget associated type for the same purpose as Deref::Target

Changes to CanTransmuteElement:

  • Added transmute_element_ method
  • Changed impls for references to return RRef and RMut
  • Changed TransmutedPtr bound to AsPtr<PtrTarget = T>

Added these InterfaceTypes in abi_stable::erased_types::interfaces

  • DEIteratorCloneInterface
  • DebugDefEqInterface

Added these #[sabi_trait] pub traits in in abi_stable::erased_types::doc_examples:

  • Doer
  • Action: used in examples of shared inherent functions of #[sabi_trait] trait objects.

Moved docs for proc macros from abi_stable::docs to the item docs.

Added abi_stable::docs::sabi_trait_inherent with documentation for the shared methods of #[sabi_trait] trait objects. This module is linked in generated code to avoid generating too much code.

Added many impls to compare between std and/or abi_stable types in both directions to:

  • RVec
  • RSlice
  • RSliceMut
  • RStr
  • RString
  • RCow

Added the abi_stable::utils::{manuallydrop_as_rmut, manuallydrop_as_raw_mut} utility functions.

Renamed abi_stable::type_level::unerasability module to downcasting, moving it to a separate file.

Renamed TU_Opaque to TD_Opaque and TU_Unerase to TD_CanDowncast.

Renamed IsImplemented trait to Implementability and its VALUE associated constant to IS_IMPLD.

Renamed all *unerase* methods to *downcast*.

Made with_move_ptr and in_move_ptr panic-safe by using guard types that deallocate the pointer on drop (even if a panic happens in the passed-in closure).

Fixed the potential soundness bug where pointers to serde_json::RawValue could change the order of the length and data pointers when transmuted to point to str.

Fixed unsoundness in, discovered by passing -Zmiri-track-raw-pointers flag to miri:

  • MovePtr::into_box: which did zero-sized allocations for zero sized types.
  • NonExhaustive::serialize: which was creating a reference which is only valid for the ScratchSpace field, but the entire NonExhaustive needed to be accessed.
  • ROnce
  • NonExhaustive::serialize_into_proxy
  • RBox::get_move_ptr
  • RString::insert
  • RString::remove
  • RString::retain
  • RVec::drain
  • RVec::retain
  • RVec::truncate

Added "rust_1_51" feature to enable const generics support.

Removed "nightly_const_params" and "all_nightly" features, since const generics have been stable for a while now.

Might not be UB, but fixed anyway:

  • RVec::as_mut_slice
  • <RVec as IntoIterator>::into_iter

Fixed unsoundness when loading library due to transmute from &'static AbiHeader to &'static LibHeader, by adding a AbiHeaderRef pointer, and loading it instead of &'static AbiHeader.

Moved the upgrade method from AbiHeader to AbiHeaderRef

Bumped dependency versions(only listing the braking ones):

  • core_extensions: 1.4
  • libloading: 0.7
  • repr_offset: 0.2

0.9.2

3 years ago

Added impls of StableAbi trait for all array lengths, conditional on the "const params" feature, and made abi_stable more resilient to changes in how static promotion works.

Changelog

Added impls of StableAbi for arrays of all sizes, conditional on the "const_params" feature.

Made abi_stable more resilient to changes in how static promotion works.

Documented that staticref only supports declaring inherent associated constants, but doesn't stop compiling anywhere else yet.

Moved continuous integration testing to github.

0.9.1

3 years ago

Fixed a memory safety bug in RString::retain and RVec::retain.

v0.9.0

3 years ago

This release doesn't have any major new features, what it has are many small to medium additions, bugfixes, and breaking changes.

The biggest changes are:

  • prefix types: using custom pointer types instead of references.

  • Flattening of abi_stable module hierarchies, leaving many items only at the submodule level (abi_stable::foo::*).

Changelog

This is copied from the Changelog.md file.

Changes

Rewrote how prefix types work. now they aren't by reference, they use static-reference-like types generated for each prefix type (those types have a _Ref suffix by default).

Flattened many module hierarchies in abi_stable, leaving many of those items only exposed where they used to be reexported.

Now #[repr(C, packed)] prefix types are forbidden.

Added a PrefixRef pointer type, which is what the *_Ref types wrap, used as the pointer to the prefix of every prefix type.

Now the #[sabi(kind(Prefix))] takes two optional arguments, prefix_ref and prefix_fields, defaulting to prefix_ref = "<DerivingType>_Ref" and prefix_fields = "<DerivingType>_Fields".

Made the root_module_loader function(declared with the #[export_root_module] attribute) be able to return anything that implements the new IntoRootModuleResult trait, including Result<_, RBoxError_>.

Declared the RootModuleError type and LibraryError::RootModule variant for the errors returned by root module loaders.

Defined the abi_stable::library::development_utils module with helper items for use while developing a dynamic library.

Made Constructor, MovePtr, RRef, NulStr, and StaticRef use NonNull instead of a raw pointer, this allows Options wrapping them to be ffi-safe.

Split off SharedStableAbi trait from StableAbi, now there's PrefixStableAbi and StableAbi, both of which only have GetStaticEquivalent_ in common.

Renamed WithMetadataFor to PrefixMedata, and added accessors for its fields.

Removed PrefixTypeTrait::into_with_metadata method,added PrefixFields and PrefixRef assoc types.

Added staticref macro for declaring StaticRef consts,added StaticRef::leak_value constructor.

Added ImmutableRef marker trait for reference-like types.

Made LateStaticRef generic over the pointer it wraps, using the ImmutableRef trait.

Renamed LateStaticRef::<&T>::initialized to from_ref.

Added the LateStaticRef::<PrefixRef<P>>::from_prefixref constructor.

Added PrefixRefTrait trait for ffi-safe pointers to prefixes.

Added the PointsToPrefixFields marker type, and PrefixRefTrait::PREFIX_FIELDS associated constant to construct it, this type is required for calling LateStaticRef::from_prefixref.

Made RootModule trait have an additional PrefixRefTrait supertrait.

Added the abi_stable::for_examples module, with types used in documentation examples.

Added Send + Sync supertraits to TypeChecker and ExtraChecks

Defined the RMut type to rewrite how #[sabi_trait] passes the method receiver.

Added sabi_as_rref and sabi_as_rmut methods to RObject and DynTrait to get RRef and RMut to the wrapped value.

Made abi_stable testable with miri

Bumped the minimum supported Rust version to 1.41.0.

Updated these public dependencies:

  • core_extensions to "0.1.18"
  • libloading to "0.6.4"
  • parking_lot to "0.11.0"
  • lock_api to "0.4.1"
  • crossbeam-channel to "0.5.0"
  • serde and serde_derive to "1.0.117"

Fixed the lack of # Unsafe docs for some unsafe traits.

Made (small) improvements to all of the documentation.

Added docs to the module that #[sabi_trait] generates, and hid methods in *_MV types (they were not supposed to be public).

Added generated docs for nonexhaustive enums, unhid the generated items, and made the generated constructors #[doc(hidden)} when the variants are.

Removed parameters of assert_nonexhaustive, using std::any::type_name internally instead.

Hid nonexhaustive_enum::GetVTable::VTABLE_REF

Added support for pinning RBox.

Added std::iter::*,Future,Hasher,Error,std::io::*, and std::fmt::Pointer impls for RBox.

Changed impl_get_type_info macro to take a :ty parameter.

Made the fields in InlineStorage types public.

Added associated constants to construct some types in abi_stable::marker_type.

Fixed handling of unsafe trait in #[sabi_trait], before this the unsafe was removed in the generated code.

Fixed an unsoundness bug where LateStaticRef<T> implemented Send + Sync even if T didn't.

Fixed an unsoundness bug where the RBpxErrpr returned from checking the layout of a library could contain references into the unloaded library, by using a new RBorError_::to_formatted_error method to stringify the error.

Changed RBox::{from_fmt, from_debug, to_formatted_error} to take references.

Added check to the declare_root_module_statics macro to safeguard against passing Self.

Fixed(?) the variance of type parameters in #[sabi_trait] generated trait object to be covariant.

Fixed RMutex::get_mut, which caused a memory leak.

Fixed RRwLock::get_mut, which caused a memory leak.

Fixed exporting of abi_stable::prefix_type::BoolArrayIter, before this it was not shown in the docs.

Made MovePtr<T> implement Send and/or Sync when T does.

Added RSliceMut::as_mut_ptr method

Removed the RSliceMut::into_slice_mut method (it was marked for deprecation)

Implemented Send and Sync for the RString and RVec iterators.

Made prefix_type::panic_on_missing_field_val private

Made TagErrorVariant private.

0.8.2

4 years ago

This release updates the layout for UnsafeCell in anticipation for a bugfix that makes UnsafeCell not propagate niches.

Changes

Breaking Change(caused by soundness fix in rustc):

This unsoundness bug for all Cell-like std types is going to be solved by making UnsafeCell not propagate niches.

In preparation for this change,this library will not propagate niches from T into *Cell<T>, this will cause runtime errors when loading libraries containing either *Cell type wrapping a type with non-zero optimizations (including references,andNonZero* types), and compile-time errors when putting Option<Cell<NonZero>> in ffi boundaries.

Dynamic libraries built on a previous patch release might have to be built from scratch, if they contain the previously mentioned types in their API.

0.8.0

4 years ago

This release comes with very minor changes API-wise,and fixes some potential unsoundness.

0.8.0

Added checks when loading dynamic libraries to ensure that Rust doesn't change how it represents zero-sized types in the "C" ABI. This means that in some rare cases,it won't be possible to link dynamic libraries across a certain Rust version because it changed how it represents zero-sized types in the "C" abi.

Added RBoxError::from_debug for constructing an RBoxError from Debug+!Display types.

Added impls of StableAbi for PhantomData of tuples.

Added the abi_stable::marker_type::NonOwningPhantom marker type, which is a more convenient way to have a PhantomData<extern "C"fn()->PhantomData<T>> field PhantomData is returned from the function because of special case support for PhantomData of tuples (eg:PhantomData<(Foo,Bar)>) (tuples don't have a stable abi,but because this is a 1-aligned zero sized type, it doesn't matter).

Fixed potential soundness bug by replacing PhantomData<extern "C" fn( $types )> fields with NonOwningPhantom<$types>.

V0.7.4

4 years ago

This release (0.7.4) adds guidelines for how dynamic libraries can be evolved, and loosens version checking inside the runtime type checker.

This includes the changelog for previous releases.

0.7.4

Added guidelines for how dynamic libraries can be evolved.

Made version checking for types looser,so that types are cómpatible so long as it's the in the same x.*,* or 0.y.* version (ignoring *).

Added functions to load the AbiHeader of a dynamic library, and to upgrade it to a LibHeader.

Added version_compatibility crates to test that pull-requests to abi_stable don't change the layout of types in an incompatible way.

0.7.3

This version constifies many functions,with some mentioned as requiring Rust 1.39 to be const.

These are the constified functions:

abi_stable::std_types::{
    RSlice::from_ref,
    RSlice::from_slice, //from Rust 1.39 onwards

    RSliceMut::{as_ptr, into_mut_ptr},

    RStr::from_str, //from Rust 1.39 onwards
    RStr::{as_rslice, is_empty},

    RString::{as_ptr, as_rstr, from_utf8_unchecked, new},

    RVec::{as_ptr, as_rslice, is_empty, new},
}

Now rstr!() won't require a literal argument from Rust 1.39 onwards, it can be any &str.

0.7.2

Bug fix:

This fixes the version number for abi_stable that is stored in dynamic libraries to always be the same as abi_stable. Before this fix the version number was 0.6 which means that you'll have to recompile dynamic libraries of previous patch versions(the 0.7.0 and 0.7.1 versions are yanked because of this).

V0.7.0

4 years ago

This release had a lot of medium-sized additions,the most important of which are:

  • A way to add extra checks to types when loading dynamic libraries.
  • A way to construct #[sabi_trait] generated trait objects in constants,and the ability to reborrow trait objects.
  • Made the type layout constants a lot smaller.
  • Support for const generics.

Changelog for 0.7

  • Added const fn constructor functions for #[sabi_trait] generated trait objects/DynTrait/RObject.

  • Added RRef<'a,T> type,as a workaround to allow transmuting &T to &().

  • Added StableAbi attributes: #[sabi(bounds=""]:for adding multiple bounds to the StableAbi impl. #[sabi(prefix_bounds=""]:for adding multiple bounds to the PrefixTypeTrait impl. #[sabi(sabi_opaque_fields]: To treat a field as opaque while still requiring it to impl StableAbi. #[sabi(sabi_opaque_fields]: To treat every field as opaque while still requiring them to impl StableAbi. #[sabi(shared_stableabi())]: replaces the default T:StableAbi bound with T:SharedStableAbi #[sabi(phantom_const_param="<expr>")] : This adds <expr> as a virtual const parameter, that is checked for equality like every other const parameter.

  • Added ConstGeneric,to have proper const-generics support, this allows any type that implements Eq+Debug+StableAbi+'static to be used as a const-parameter.

  • Added macros for constructing RVec/Tuple0-4/RStr/RSlice/NulStr

  • Added NulStr,a nul terminated utf8 string slice.

  • Rewrote how type layout constants are represented to be significantly smaller. Most of the optimizations are described in the ffdd68fef8d445d7d91972b0d751db80df887ec4 commit (there were some tweaks after that commit,but it's mostly correct).

  • Now #[sabi_trait]trait Trait:'static{} allows the trait object to be constructed from a non-'static reference to a 'static type, removing lifetime supertraits from Trait in the generated code. Now generates a Trait_Bound trait with all the supertraits(including lifetimes).

  • Renamed #[sabi(field_bound="")] to #[sabi(accessor_bound="")], because it only adds a bound to the accessor methods of prefix types.

  • Merged the abi_stable_derive_lib crate into the abi_stable_derive crate.

  • Changed error reporting in proc macros to report as many errors as possible, pointing at what the cause of the error is.

  • Added reborrowing support to #[sabi_trait] generated trait objects.

  • Changed TypeInfo to use std::any::type_name to print the type in error messages from 1.38 onwards.

  • Renamed DynTrait/RObject unerasure methods for the common case.

  • Split TransmuteElement into the CanTransmuteElement marker trait and the TransmuteElement extension trait

  • Now forbidding type macros,they will be allowed once referenced lifetime can be detected inside macro invocations.

  • Added Debug and Display support in RObject.

  • Added a way to add extra checks to type layouts at load time with #[sabi(extra_checks="")],passing a type that implements ExtraChecks. Replaced uses of #[sabi(tag="...")] by DynTrait/RObject/NonExhaustive.

  • Made it possible to borrow from self in SerializeProxyType.

0.6.3

4 years ago

This patch release features the addition of example documentation to almost every type/method in abi_stable::{external_types,sabi_types,std_types}.

Changelog from 0.6.0

0.6.3

  • Added documentation examples to virtually every type/method in abi_stable::{external_types,sabi_types,std_types}

  • Added a few methods/associated functions because examples made it obvious that they were necessary.

  • Changed RBoxError_ downcast methods to downcast through a Box<dyn Error+ ... > if it wraps one.

    This involves a tiny breaking change where downcast now requires std::error::Error to be implemented by the error being downcasted. This breaking change should not be a problem, since RBoxError::{new,from_box,from} requires that the type implements the Error trait, meaning that one can only sensibly downcast to types that implement the trait

  • Added ROnce::NEW associated constant as a workaround for a compiler bug

  • Added abi_stable::inline_storage::alignment::AlignToUsize

0.6.2

  • Added the #[derive(GetStaticEquivalent)] derive macro.

  • Added #[sabi(impl_InterfaceType())] helper attribute to #[derive(StableAbi)] and #[derive(GetStaticEquivalent)].

  • Replaced most uses of impl_InterfaceType!{} with the helper attribute.

  • Added comments explaining abi_stable concepts in examples.