Question
ryan vanslyke · Apr 24, 2020

Rust bindings for Caché

I've noticed Caché has bindings for several languages. Would there be a reason to, or are there any plans to include bindings for the Rust language? I haven't been able to find any information on the topic.

1
0 257
Discussion (3)2
Log in or sign up to continue

Would be a great language to add.

Are you interested in calling Rust code from InterSystems IRIS or interfacing with InterSystems IRS from Rust?

Currently you can use Callin/Callout functionality for C/C++ and calll that from Rust.

A while ago I was trying Rust and successfully transpiled C callout library into Rust callout library and compiled it as Rust shared lib and it works (callable from InterSystems IRIS).

For this community project to take off two issues need to be solved:

  • Doing something with a lot of generated boilerplate <- Easy part, can probably just dump it into external file as is
  • Generating appropriate ZFEntry table. <-Probably possible but I have not researched the issue so far

I agree that the most likely path to a Rust binding is to wrap a C or C++ API. If you're content with a local client, callin and/or callout is the place to start. As you said, it shouldn't be too hard to write a callout library in Rust. Callin, on the other hand, (and callback from a callout library) is a bit more involved, requiring a lot of unsafe code.

If you want a remote client, you could look at wrapping the C or C++ binding, but that's a dead end that is not supported in IRIS. You might also look into relational access or an ORM. Diesel looks promising, but I don't know whether it (or Rust in general) works well with ODBC.

For my current use case, I'm only using Cache, not IRIS, so I'm not sure what the difference would be. I suppose the Callin/Callout option would be ideal, and I've started researching it through your pointers, though I have no experience with much of it.

Perhaps there's the relational access option as well. There's Diesel as mentioned, as well as the odbc Rust crate that wraps the raw C interface.