Skip to content

Releases: matsadler/magnus

0.8.2

08 Oct 03:39

Choose a tag to compare

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

06 Sep 20:15

Choose a tag to compare

Magnus 0.8.1 is a patch release, with 1 bug fix.

Fixes a compilation error on 32-bit platforms. Thanks to @jonian for reporting this issue.

See the 0.8.0 release for what's new in 0.8.

0.8.0

26 Aug 02:44
108c87e

Choose a tag to compare

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 fatal exception raised when a Rust function bound to Ruby panics can no longer be caught with rescue Exception.
  • Fixed type bounds for TryConvertOwned for (T, ...) so that T must be TryConvertOwned.

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

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

30 Jun 22:00

Choose a tag to compare

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

30 Jun 21:27

Choose a tag to compare

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 Thread api via methods to create threads on the Ruby type and the Thread type.
  • Support for Ruby's Mutex api via methods to create a mutex on the Ruby type and the Mutex type.
  • Support for Ruby's Fiber api via methods to create fibers on the Ruby type and the Fiber type (on Ruby versions 3.1 and up).
  • A Time type representing instances of Ruby's Time class that will convert to/from std::time::SystemTime.
  • r_array::TypedArray, a Ruby Array that may only contain elements of type T. 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::Integer now implements PartialEq, PartialOrd, Add, Sub, Mul, and Div so it can be used with mathematical operators like + and -.
  • Ruby::define_data for working with Ruby's Data class (Ruby 3.3 and up only).
  • RArray implements IntoIterator.
  • IntoError is a new trait for converting types to magnus::Error. Functions returning to Ruby can now return Result where the error type is any type that implements IntoError.

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

09 May 05:34

Choose a tag to compare

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

01 Apr 02:25

Choose a tag to compare

Magnus 0.6.3 is a patch release, with 1 fix.

Adds missing IntoValueFromNative implementations for Vec and HashMap. This was preventing converting nested Vecs to Ruby Arrays. See issue #105.

Thanks to @Vagab for reporting this issue.

0.6.2

19 Sep 00:04

Choose a tag to compare

Magnus 0.6.2 is a patch release, with 1 fix.

Fixes a compile error using the bytes feature. See issue #90.

Thanks to @jwilm for reporting this issue.

0.6.1

20 Aug 23:46

Choose a tag to compare

Magnus 0.6.1 is a patch release, with 1 change.

This release adds support for rb-sys' stable-api feature.

Thanks to @gmalette for this change.

0.5.5

20 Aug 23:45

Choose a tag to compare

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"] }

Thanks to @gmalette and @ianks for this change.