Module magnus::rb_sys

source ·
Available on crate feature rb-sys-interop only.
Expand description

Functions for interoperability with rb-sys.

These functions are provided to interface with the lower-level Ruby bindings provided by rb-sys. You may want to use rb-sys when:

  1. Magnus does not provide access to a Ruby API because the API can not be made safe & ergonomic.
  2. Magnus exposed the API in a way that does not work for your use case.
  3. The API just hasn’t been implemented yet.

Even if you are not in a position to contribute code to Magnus, please open an issue outlining your use case and the APIs you need whenever you find yourself reaching for this module.


Functions in this module are considered unstable. While there is no plan to alter or remove them, non-backwards compatible changes in this module will not necessarily be considered as SemVer major changes.


The unsafe functions in this module are capable of producing values that break the saftey guarantees of almost every other function in Magnus. Use them with care.


Trait to convert a Id to a raw ID.
Converts from a Value to a raw VALUE.
Trait to convert from a raw ID to an Id.
Converts from a raw VALUE to a Value.


Attempts to catch cases of Rust unwinding, converting to a fatal Error.
Calls the given closure, catching all cases of unwinding from Ruby returning them as an Error.
Resumes an Error previously caught by protect.