Releases: matsadler/magnus
0.8.2
Magnus 0.8.2 is a patch release, with 1 bug fix.
Fixes an incorrect error message when converting a Ruby string to a Rust string fails. Thanks to @jeffcharles for this fix.
See the 0.8.0 release for what's new in 0.8.
0.8.1
0.8.0
Magnus 0.8.0 adds a handful of features and fixes. The old-api feature introduced in 0.7.0 is no longer a default feature, so functions marked as part of the old API will be deprecated by default. Otherwise it is largely compatible with 0.7.
Magnus is a Rust library providing a high-level easy-to-use interface to the C API of the Ruby programming language. Magnus lets you write Ruby extension libraries (or 'gems') in Rust, or embed Ruby in your Rust program.
Fixes
- The
fatalexception raised when a Rust function bound to Ruby panics can no longer be caught withrescue Exception. - Fixed type bounds for
TryConvertOwnedfor(T, ...)so thatTmust beTryConvertOwned.
API changes
The minimum supported Rust version in now 1.65.
Magnus 0.5 and earlier would allow you to create Ruby objects with associated functions, like RArray::new. In Magnus 0.6 a new set of APIs for creating Ruby objects was added, as methods on a Ruby handle that can only be obtained on a Ruby thread. The older associated functions API is now marked as deprecated by default. The old-api feature can be enabled to disable deprecation warnings for the old API. In a future version of Magnus will remove this feature.
The FString type has been removed as it can not safely uphold the promise it was making. Either due to Ruby's apis changing or a misinterpretation of old documentation it had been designed assuming interned strings (aka 'fstrings') would not be garbage collected, which is not the case.
Conversions between Ruby's Time and Rust's SystemTime now preserve nanosecond precision.
RString::to_string will now use a Ruby utf-8 validation api that caches the results of the validity check. This will greatly improve performance in the case a string is already known to be utf-8, but may slightly reduce performance when not known.
New Features
Ruby::time_nano_new,Ruby::time_timespec_new, andTime::timespec.- The
chronofeature can be enabled to allow automatic conversions betweenchrono::DateTime<Utc>andchrono::DateTime<FixedOffset>and RubyTimeobjects. typed_data::Writebarrier::writebarrierandwritebarrier_unprotect.- Automatic type conversions for
NonZerotypes,i128/u128, andBTreeMap. Ruby::io_extract_modeenc.
Upgrading
Upgrading from Magnus 0.6 or 0.7 should be straightforward. If upgrading from 0.5 or earlier, it's recommended to upgrade to 0.6 first.
FromIterator for RArray and RHash are hidden behind the old-api feature (which will be removed in a future version of Magnus). Use Ruby::ary_from_iter and Ruby::hash_from_iter rather than RArray/Rhash::from_iter or collect::<RArray>()/collect::<RHash>().
See the changelog for all the changes.
Thanks
@ankane for implementing TryConvert for NonZero types, i128/u128 support, and some additional improvements.
@emwalker for the chrono feature.
@erickguan for improvements to docs, some fixes, and IO features including Ruby::io_extract_modeenc.
@ianks and @sandbergja for other fixes.
@yaroslav for a detailed issue report that lead to an improvement.
0.7.1
Magnus 0.7.1 is a patch release, with 1 documentation fix.
Fixes building docs against Ruby 3.0. This should resolve building docs for docs.rs.
See the 0.7.0 release for what's new in 0.7.
0.7.0
Magnus 0.7.0 adds many features, but should be largely compatible with 0.6.
Magnus is a Rust library providing a high-level easy-to-use interface to the C API of the Ruby programming language. Magnus lets you write Ruby extension libraries (or 'gems') in Rust, or embed Ruby in your Rust program.
API changes
Magnus 0.5 and earlier would allow you to create Ruby objects with associated functions, like RArray::new. In Magnus 0.6 a new set of APIs for creating Ruby objects was added, as methods on a Ruby handle that can only be obtained on a Ruby thread. 0.7 begins the deprecation of the associated functions with the old-api feature. This feature is enabled by default, but if disabled the old-api functions will issue deprecation warnings. Disable this feature to get an early start on migrating these functions to the new API.
As part of the same effort, closures and functions used as Ruby blocks or procs now take an additional first argument of &Ruby.
The ruby-static feature has been removed. Instead enable the feature for rb-sys in your Cargo.toml like so:
rb-sys = { version = "*", features = ["ruby-static"] }New Features
- Support for Ruby's
Threadapi via methods to create threads on theRubytype and theThreadtype. - Support for Ruby's
Mutexapi via methods to create a mutex on theRubytype and theMutextype. - Support for Ruby's
Fiberapi via methods to create fibers on theRubytype and theFibertype (on Ruby versions 3.1 and up). - A
Timetype representing instances of Ruby'sTimeclass that will convert to/fromstd::time::SystemTime. r_array::TypedArray, a Ruby Array that may only contain elements of typeT. On creation the Array is hidden from Ruby, and must be consumed to pass it to Ruby (where it reverts to a regular untyped Array). It is then inaccessible to Rust.magnus::Integernow implementsPartialEq,PartialOrd,Add,Sub,Mul, andDivso it can be used with mathematical operators like+and-.Ruby::define_datafor working with Ruby'sDataclass (Ruby 3.3 and up only).RArrayimplementsIntoIterator.IntoErroris a new trait for converting types tomagnus::Error. Functions returning to Ruby can now returnResultwhere the error type is any type that implementsIntoError.
Upgrading
Upgrading from Magnus 0.6 should be straightforward. If upgrading from 0.5 or earlier, it's recommended to upgrade to 0.6 first.
See the changelog for all the changes.
Thanks
@Maaarcocr for implementing the Add et al traits for Integer.
@adampetro for contributions to the implementation of IntoIterator for RArray.
@macournoyer for fixes to Error.
@y-yagi and @gjtorikian for fixing typos.
0.6.4
Magnus 0.6.4 is a patch release, with 1 fix.
Lazy could deadlock when called for the first time from multiple threads simultaneously.
The fix for results in a slight change in expected behaviour. If multiple threads attempt first access at the same time the func given to Lazy::new may be called more than once, but all threads will receive the same value.
Thanks to @choubacha for reporting this issue, along with an excellent repro.
0.6.3
0.6.2
0.6.1
0.5.5
Magnus 0.5.5 is a patch release, with 1 change.
This release adds support for rb-sys' stable-api feature. This necessitates upping the minimum supported Rust version to 1.60.
Additionally, Ruby 2.6 support requires enabling rb-sys' stable-api-compiled-fallback feature in your Cargo.toml like so:
rb-sys = { version = "*", default-features = false, features = ["stable-api-compiled-fallback"] }