Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/manchicken/rust-interoperability-in-perl

A prototype repo for testing Rust interoperability in Perl.
https://github.com/manchicken/rust-interoperability-in-perl

Last synced: 18 days ago
JSON representation

A prototype repo for testing Rust interoperability in Perl.

Awesome Lists containing this project

README

        

# rust-interoperability-in-perl

A prototype repo for testing Rust interoperability in Perl.

## What is it?

I'm looking at doing some stuff with interoperability between Perl and Rust. This is my test-bed.

## Prerequisites

These C libraries are needed:

- `libffi` with headers
- `libssl` with headers

You will also need a Rust environment. If you don't know how to set this up yet, consider using [rustup](https://rustup.rs/).

You'll also need to install Carton:

```sh
cpan Carton
```

(`cpanm` will work, too, if you have `App::Cpanminus` installed)

## Running

### Short version

1. Build the Rust code with `cargo build` (right now I'm only using the `debug` target)
2. Run the scripts individually

### Longer version

```sh
cd rust-part; cargo build; cd -
carton install
perl ./add_two.pl
```

## The files

The `cpanfile` and `cpanfile.snapshot` are artifacts for the [Carton dependency manager](https://metacpan.org/pod/Carton).
Carton will install the modules in a directory called `local` in the working directory.

The `rust-part` folder contains a normal Rust program, but it's a `cdylib` crate so it'll produce a `.so` file.

The scripts themselves are just in the top-level directory, with a `.pl` extension.

## The tests

- Simple adding of two integers (`add_two.pl`)
- Upper-casing a string (`upper_string.pl`)
- Using an opaque pointer in Perl (`opaque_kvp.pl`)
- Using Tokio async (TBD)
- Invoking a Perl callback (TBD)