Rust in Samba example code and slides

Simo simo at samba.org
Thu Jun 7 13:00:05 UTC 2018


On Thu, 2018-06-07 at 10:18 +0200, Kai Blin via samba-technical wrote:
> Hi folks,
> 
> I've been asked about the example code and slides for the talk I gave
> at SambaXP yesterday. You can find the code at:
> 
> https://github.com/kblin/fancy-talk
> 
> The slides are linked from the README, and can be found at:
> 
> https://kblin.org/talks/sambaxp/2018/rust_in_samba.html#1

Pretty cool Kai,
however my heart sank when I saw talloc in Rust.

I think one of the key features about Rust (and its safety) is that the
compiler handles memory, I wouldn't want to use talloc in there :-)
I would rather pay the price of copying memory at the edges if we
really have no options, or simply have a wrapping talloc construct that
wraps Rust structures like:

struct talloc_wrap {
    Rust owned memory here
};

When you receive the memory from rust you'd slap the talloc_wrap in the
memory hierarchy so that will take care of freeing stuff via a
destructor, then use the result. The only gotcha will be that you can't
steal any Rust returned buffers, but that seem a small price to pay,
worst case you copy it out.

Simo.



More information about the samba-technical mailing list