Skip to content

Releases: matsadler/magnus

0.5.2

19 Mar 17:36
Compare
Choose a tag to compare

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

Fixed compilation issue in RBignum on 32 bit platforms. Thanks to @yammine for reporting this.

0.5.1

18 Feb 19:29
Compare
Choose a tag to compare

Magnus 0.5.1 is a patch release that improves documentation. Thanks to @y-yagi and @dylanahsmith.

0.5.0

11 Feb 16:41
Compare
Choose a tag to compare

Magnus 0.5.0 adds many features, a handful of fixes, and some API changes.

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

RStruct was missing an implementation of the ReprValue trait that would allow it to be passed to functions that require a value that is already a Ruby object. This trait implementation has now been added.

When converting Ruby values to RArray (or Vec<T>, [T; 1], or (T,)), an error will now be returned if given a non-Array (or non to_ary-able) value, rather than wrapping it in an array (see RArray::to_ary for the old behaviour).

Changes

There have been some internal changes to start making Magnus safe to use with multithreaded code. Many functions are now documented as panicking when called from a non-Ruby thread. This check is currently only performed in debug builds, as there is no api to avoid the performance hit of this check (calling these functions from a non-Ruby thread in a release build is undefined behaviour).

The IntoValue trait is now used instead of Into<Value> for converting to Ruby types. The Into<Value> implementations will be removed in the next release.

use magnus::prelude::* will now import traits anonymously.

New features

The bytes-crate feature can be enabled to allow automatic conversions between bytes::Bytes and Ruby strings.

typed_data::Obj<T>, is a Ruby object wrapping a Rust type known to be T. Previously you could declare a function accepting &T to receive a reference to the Rust data wrapped in a Ruby object, but you wouldn't have access to the wrapping object. Or if you declared the argument as Value you could get the wrapping object, but it was awkward to get the inner Rust data. typed_data::Obj<T> gets you the best of both worlds. See the typed_data_obj.rs test for an example.

TypedData::class_for can be implemented to customise the class on a case by case basis when wrapping Rust data in a Ruby object. See the docs for details. A simple interface to this is enabled with the #[wrap] macro now allowing #[magnus(class = "...")] attributes on enum variants.

The typed_data::Hash and typed_data::IsEql traits are automatically implemented for compatible types, providing Ruby compatible #hash and #eql? methods ready to be bound to your object.

error::Result<T> as a shorthand for std::result::Result<T, Error>.

The following Ruby API functions are now implemented in Magnus:

See the changelog for more details.

Thanks

  • @ianks for continued improvements to the foundational rb-sys crate, the idea for the typed_data::Obj<T> feature, some CI improvements for Magnus, and the auto wb_protected flag feature.
  • @gjtorikian for reporting the surprising Array conversion behaviour.
  • @georgeclaghorn for adding funcall_public and error::Result<T>.
  • @Maaarcocr for reporting an issue where Vec<Value> could be passed as an argument to Ruby (Value should never be stored in a heap allocated struct like Vec) that inspired the design of the IntoValue trait.
  • @ankane for the idea behind TypedData::class_for and #[magnus(class = "...")] on enum variants.
  • @elct9620 for reporting an issue with embed::init and the ruby-static feature that resulted in a change that gives better error messages from embed::init.
  • @cramt for the bytes-crate feature.

0.4.4

24 Dec 19:20
Compare
Choose a tag to compare

Magnus 0.4.4 is a patch release, with 1 addition and 1 bug fix.

Added is Class::undef_alloc_func, a function to remove a class' allocator function.

Fixed 'wrapped' structs from #[wrap] and #[derive(TypedData)] macros generating warning: undefining the allocator of T_DATA class under Ruby 3.2.

Thanks to @jbourassa for these changes.

0.4.3

08 Dec 03:57
Compare
Choose a tag to compare

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

Fixed a bug where gc::mark_slice was failing to mark the last element of the slice. Thanks to @jbourassa for the fix.

0.4.2

30 Nov 17:11
Compare
Choose a tag to compare

Magnus 0.4.2 is a patch release that removes an errant dbg!() call.

0.4.1

30 Nov 04:43
Compare
Choose a tag to compare

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

Fixed bug where scan_args::get_kwargs could error/segfault when leading optional args were not provided, due to trying to convert the type of the missing value. Thanks to @gjtorikian for reporting this.

0.4.0

19 Nov 17:30
Compare
Choose a tag to compare

Magnus 0.4.0 adds a handful of new features and fixes. Support for different platforms has been greatly improved.

Magnus is a Rust library binding 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.

Magnus has switched from our own built in bindings to Ruby to using the rb-sys crate. This, along with the rb-sys gem, greatly improves the compatibility and reliability across different platforms and Ruby versions. Notable improvements include:

  • Support for cross-compilation
  • Improved static linking support
  • Support for Ruby 3.2 preview
  • Support for mswin/msvc platform with Ruby 3.2
  • Support for Xcode 14

Thanks to @ianks for all his hard work on this.

Additions around exceptions make for easier defining of custom exceptions. See examples/custom_exception_ruby and examples/custom_exception_rust.

Notable fixes include:

  • Calling and creating Ruby blocks/procs should be much more reliable.
  • Fixed a memory leak of the error message when returning an Error to raise an exception.
  • Flonum support disabled on platforms where it is not supported. This allows compiling Magnus on 32 bit systems (though full 32 bit support is not yet guaranteed).

See CHANGELOG.md for full details.

Thanks

0.3.2

30 May 01:09
Compare
Choose a tag to compare

Magnus 0.3.2 is a patch release, with 2 bug fixes.

Better error output from the build script when ruby can't be found or errors. Thanks to @ms-jpq for this fix.

Fixed crash in Proc::new and Value::block_call when the proc was stored and called later.

0.3.1

22 May 05:29
Compare
Choose a tag to compare

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

Fixed Integer overflow in Ruby Float to f64 conversion.