mmmrrr
The starting point: The Erlang ODBC client has a “bug” where it only allows 4096 bytes to be returned per cell. The Rust odbc client has no such limitations.
The reasoning: I’d like to avoid Rust for the web layer, since that would result in a lot of training for my peers.
The (probably insane) idea: Use Rustler to provide a custom “odbc driver” that can be used from Elixir.
The problem: I’d need to store the established connections somewhere in Elixir in order to pass them to the query functions and I’m not quite sure if this would work with Rustlers unsafe functions.
So the questions are:
- How do I return a Rust reference to a “thing” to Elixir in order to pass it again to Rust later on?
- Is there anything that disqualifies this idea categorically (except from the fact that it is probably a huge effort)
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hauleth
Use NIF resource for that, you probably will need to dig in Rustler docs how to do that in Rust.
tessi
@hauleth 's suggestion is on point.
If you need an example, you could look at wasmex (GitHub - tessi/wasmex: Execute WebAssembly from Elixir · GitHub).
For example, a WebAssembly module instance has an elixir representation with an attached Rust struct. It is passed down in some methods defined here to the Rust-layer.
In Rust-land, we override the Wasmex::Native module with the respective rust functions taking that rust-struct reference.
In
instance.rsyou can see how to attach structs (instancein my case) to elixir objects (new_from_bytes) and how to extract structs from elixir objects (e.g.function_export_exists).dimitarvp
Rustler
0.22.0-rcmakes this a bit easier. It’s not very well documented but I’ve made it work mostly easily.mmmrrr
Could you give me a pointer (pun fully intended
), Dimitar?
I. e. what exactly is it that the new version will make easier?
dimitarvp
Here’s something that should work with minimal changes:
You might need to remove the lifetime qualifiers though, can’t remember why my code needed them now. Using Rustler’s
ResourceArcis crucial here; thanks to it you will receive the Rust object wrapped in a nice ErlangReferencewhich in the case of this function you’ll see in youriexconsole like so (in the case of success):…or in case of failure:
Then on the Elixir side you should take care to have the same
something()function that Rustler will wrap and pass through to Rust (this is covered in Rustler’s guide). That’s basically it. Poke me if you need more help, Rustler could be tricky and it seems the maintainers don’t have time for it for a long time now.mmmrrr
Sweet! Thank you so much
(all of you that is ^_^)
I’ll try that once I get to that project again next week. This looks really promising.
BobbyMcWho
I am also interested in doing this, I’m experimenting with something and will need to pass a reference to a rust object(? My rust knowledge is poor) to elixir so that I can later call other rust methods to it
mmmrrr
@dimitarvp I tried to implement the solution you suggested with rustler
0.22.0-rc.0.I now have the problem that the
YOUR_RUST_TYPE_HEREtype that I used instead does not implement theResourceTypeProvidertrait and I’m unsure how to impl that correctly… did you have to provide the trait implementation for the type you used in your application?dimitarvp
Doesn’t ring a bell from memory. Do you have a GitHub repo for me to look at?
EDIT: Actually this might be because you have incorrectly implemented
Encoder– but not 100% sure.mmmrrr
Unfortunately no because the whole construct is a little complex by now…
But here is the actual code in the rust lib:
odbx::is a package I wrote to patch and adjust several rust odbc packages (which is what makes this whole thing a little complicated…)The compiler is complaining about the
Success(ResourceArc<DbConnection>), sinceConnection<AutocommitOn>does not implement the traitResourceTypeProvider