Skip to content

Implementation of Rust FFI Omnibus examples with raku NativeCall

License

Notifications You must be signed in to change notification settings

librasteve/raku-Inline-Rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raku-Inline-Rust

WORK IN PROGRESS

Description

Since Rust is a compiled language and Raku connects to a Rust cdylib directly via the core NativeCall capability, this raku module is more of a "how to" set of examples.

It has been dubbed Inline::Rust to follow the naming convention of similar Raku interface modules (but no actual Raku code is needed to make these examples work since NativeCall works out-of-the-box).

The use case provided is for a Raku programme to access Rust library functions (e.g. for performance and re-usability).

Source Material

The raku examples are inspired by the Rust FFI Omnibus and they have been offered back for inclusion into this guide.

Getting Started

docker run -it p6steve/raku-dan:polars-2022.02-arm64   
(or edit the FROM --platform=linux/amd64 p6steve/rakudo:ubuntu-latest-amd64 and docker build... if you need Intel x86)
cd ~ && git clone https://github.com/p6steve/raku-Inline-Rust.git
cd raku-Inline-Rust
raku ffi-omnibus.raku

Do It Yourself

To make a new cdylib, you can do this:

 cargo new --lib your-name && cd your-name
 vi Cargo.toml, add [dependencies] and [lib] sections (see example)
 vi src/lib.rs, write some Rust code (see example)
 cargo build
 cd .. && vi your-name.raku, write some Raku code (see example)
 raku your-name.raku

About

Implementation of Rust FFI Omnibus examples with raku NativeCall

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published