rust_interop_d ~main

Rust interop for D.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

librust_interop

Rust interop with other programming languages: C, D, ... etc.

Mainly to make high performant, memory safe Rust libraries available to other languages users.

Recently wrapped:

  • DashMap: is an implementation of a concurrent associative array/hashmap in Rust. dashmap-5.3.4 Blazing fast concurrent HashMap for Rust. https://docs.rs/dashmap/5.3.4/dashmap/struct.DashMap.html
  • SegQueue: An unbounded multi-producer multi-consumer queue. https://docs.rs/crossbeam-queue/0.3.5/crossbeam_queue/struct.SegQueue.html

Note:

Right now:

  • only u64 is used as key type, and value type
  • so for value type: only pass integer type or pointer type to the container.

We use the same memory management method as liblfdsd: https://github.com/mw66/liblfdsd#memory-management-remember-this-is-a-thin-wrapper-lib-in-d

Let Rust's be Rust's, and let D's be D's, i.e.

  • Rust manage Rust's memory (the container), and
  • D manage D's memory (the objects)

The only thing interfacing between Rust and D is the simple uintptr_t (void*) as value, so to use this D library:

all primitive types (whose .sizeof upto pointer size on the target machine) | class (pointer)'s value are stored as value of uintptrt everything else, i.e. all (fat) objects' address are stored as value of uintptrt

The only extra requirement on the D side is to keep reference to those fat objects to avoid it being GC-ed before being pop-ed.

(Just as: don't push a stack var into any-type-of queue, and pop it after the stack is gone -- this is the responsibility of the programmer, not the container.)

That's all.

And please remember to keep a reference on the D side of the fat objects you put in the container:

Pre-req:

  • Rust nightly: for https://github.com/dtolnay/cargo-expand
  • cbindgen: https://github.com/eqrion/cbindgen
  • dpp: https://code.dlang.org/packages/dpp
  • dstep: https://code.dlang.org/packages/dstep
Authors:
  • yilabs
Dependencies:
liblfdsd
Versions:
0.2.7 2022-Aug-12
0.2.6 2022-Jun-05
0.2.5 2022-Jun-04
0.2.4 2022-Jun-04
0.2.3 2022-Jun-04
Show all 9 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 29 downloads total

Score:
0.5
Short URL:
rust_interop_d.dub.pm