the_wildgoose

the_wildgoose

Hi, I had a need for applying Reed Solomon protection to a (short) string. Think that you have a few hundred bytes and want to protect it against a couple of characters getting garbled, so you run it through the encoder, it creates a slightly longer string. Then later you can run (whatever makes it to the far end) through the decoder and repair any corruption. Think perhaps QR code protection, or protecting a long license key so it still works if you mistype, etc

However, a more common use case for Reed Solomon is to apply it to larger packets. For example PAR2 encoding slices a file into chunks and then encodes a protection stripped across all the chunks, so if a few were “erased”, you can recover them using the recovery packets

In a nutshell the encoding can be applied to even sized chunks and will protect against N/2 of those chunks going missing, where N is the amount of parity blocks you add

I wrapped two rust libraries. Why? Because I wrapped the high speed “reed-solomon-simd” library before realising that it wasn’t useful for my use case (protecting short strings), so I then wrapped a the simple reed-solomon-rs library which solves my use case. However, I’ve wrapped and released both libraries here:

https://github.com/ewildgoose/elixir-reed_solomon_simd

https://github.com/ewildgoose/rs_protect

Broadly you want the top one for protecting big lumps of data, such as IP packets, files, RAID on your disk, etc. And you want the second for encoding data on QR codes, or protecting small strings. Credit to the original authors as all I’m going is wrapping their work.

It’s my first attempt at writing some Rustler code, so feedback appreciated, also if anyone wants to give some guidance on how to pre-compile binaries for different platforms?

Showing Posts 1 to 3

dimitarvp

dimitarvp

As I start I would recommend you not using .map_err to return a String. I’d make my own Error enum and have it implement Display (and maybe Debug as well) for such cases.

Or, even better, just implement rustler’s Encoder for it and map it to error tuples.

(Still use .map_err though, that’s how it’s done when you want to use ? and return Result-s but need your own custom error and want it serialized as an Elixir value.)

Or all of the above. I am doing that in my library (dimitarvp/xqlite on GitHub). Could send you a small PR if I have the time, though that’s not very likely, admittedly.

the_wildgoose

the_wildgoose OP

That’s a very helpful reply! Thank you!

I concede I’ve little idea what I’m going here… I am cargo culting a lot, and struggled significantly to figure out how to get the rustler mapping to work. I’ve zero idea where to start on those suggestions, but I’ll take a peek at your project, thanks for the link!

Obviously will not turn down PRs! Thanks

dimitarvp

dimitarvp

Find the error.rs file in my project, and then look for impl rustler::Error for XqliteError (or just impl Error).

That should unblock you IMO.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
marciok
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
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
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

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews