[Thiago Cafe] Programming is fun!

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember

Deserialising binary data in Rust

(Posted 2024-08-14 17:11:15)

One common way to deal with serialised data in C++ is to map to a struct, but in Rust with memory ownership and some smart memory optimizations, it is a little more complicated.

For example, let's say a producer in C++ serialises this message:

struct book_msg {  
    uint8_t major_version, // byte 0: message major version  
    uint8_t minor_version, // byte 1: message minor version  
    uint8_t msg_type,      // byte 2: message type  
    uint8_t title[20]      // byte 3-23: title of the book  
}
// ....
auto msg = create_msg();
comm.send(&msg, sizeof(book_msg));

How can we deserialise that in Rust?

... more ...

How to use Flatbuffers in a C++ project with Conan?

(Posted 2024-02-01 20:04:40)

In a C++ project I am currently working, we are using CMake/Conan for dependency resolution and planning to use flatbuffer to serialise some messages. When searching for documentation, I noticed that flatbuffers documentation is not the best one and that the integration with CMake is even harder to find, therefore, I decided to write a recipe on how to integrate it to reduce the misery of other developers around.

First, let me explain quickly how it works.

... more ...

Having fun in life!

(Posted 2017-09-10 10:42:42)

I was talking to a friend about cellular automata using Conway's Game of life as an example. Curious again after so many years that I've read it, I read again carefully the wikipedia page and I found it fascinating.

What is the better way to learn more? Implementing! However I do not want to implement it in a boring way. I want to have interesting features. Let's first talk a little bit about this 0-player fascinating game.

... more ...

Pages: 1

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember