Skip to content

Releases: matsadler/magnus

0.3.0

18 May 19:11
Compare
Choose a tag to compare

Magnus 0.3.0 adds many new features and includes a number of fixes.

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.

A large portion of Ruby encoding API has been added, this includes creating Ruby strings in any encoding, converting between encodings, iterating a Ruby string's codepoints, testing a character's type, and an optimisation to RString::as_str that can avoid utf8 validity checks when that information is already known by Ruby.

Conversions between Ruby's integer and float format and the native types used by Rust has seen dramatic performance improvements, and is now on-par with C performance.

Ruby Proc objects can now be created from a Rust closure.

Many functions, plus BoxValue, that were previously stuck using the base Ruby Value type can now accept any Ruby type. Along the same lines, arguments to the closure of RHash::foreach are not longer forced to Value and can now participate in automatic type conversion.

For anyone already familiar with Ruby's C API, or taking advantage of documentation or guides assuming use of C an index has been added to the documentation mapping C functions to Rust functions in Magnus. This currently only lists the parts of Ruby's API implemented in Magnus, and is missing some cases where Magnus has equivalent behaviour, but it isn't directly implemented in terms of the C API. This will be expanded in future releases.

Many additional methods for the core Ruby classes String, Array, and Hash:

The rb-sys-interop feature swaps out the built in low-level bindings to Ruby for rb-sys and enables a module with functionality for interoperability. Future versions of Magnus will switch to rb-sys, and this feature should be considered a preview. Please give it a try and feedback is welcomed.

A handful of bugs have been fixed, including:

  • A crash when creating a StaticSymbol from a &str with characters outside the ASCII range.
  • A couple of cases where panics could cross over to Ruby with the potential for Undefined Behaviour.
  • define_*_method functions now return an error, as they are in fact fallible.

And many more changes, see CHANGELOG.md for more details.

Thanks

0.2.1

17 May 04:18
Compare
Choose a tag to compare

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

Fixed compilation error in method! and function! macros with arity argument of 5.

0.2.0

17 May 04:15
Compare
Choose a tag to compare

Magnus 0.2.0 brings a number of new features and fixes to Magnus.

Magnus is a Rust library binding to the C API of the Ruby programming language. Magnus lets you write Ruby extension libraries in Rust, or embed Ruby in your Rust program.

This release brings improvements to the documentation, adding doc examples to large parts of the API. As the doc examples are run as part of the tests, this also improves the test coverage in Magnus.

scan_args and get_kwargs functions have been implemented for complex argument handing. These functions are driven by the type parameters in their return type, adding a compile-time checked layer atop the base API exposed by Ruby.

Value::block_call allows for calling Ruby methods, passing a Rust closure as a 'block' parameter.

See CHANGELOG.md for more details.

0.1.0

17 May 03:58
Compare
Choose a tag to compare

Magnus 0.1.0 is the first release of Magnus, Rust bindings to the C API of the Ruby programming language. Magnus lets you write Ruby extension libraries in Rust, or embed Ruby in your Rust program.

This first release includes, support for most core Ruby classes, String, Symbol, Integer, Float, Array, Hash and more.

Rust functions can be bound as Ruby methods, with automatic conversion between Ruby objects and Rust types for arguments and return values. This includes returning Rust's Result to raise a Ruby Exception.

Ruby methods can be called from Rust, again with automatic type conversions, including Ruby Exceptions converted to Rust's Result.

See CHANGELOG.md for more details.