Storage of UUID

How exactly are UUIDs stored in rust? I know that they are 128-bit numbers, and I read that they are stored as 16 octets. But I don't fully understand what that means.
Are they stored in stack or heap? They have a fixed size, so my guess is stack, but I am not sure of it.

There are a few ways that you can store it, what you are describing is something like this,

struct UUID([u8; 16]);

A u8 is an octect of bits, so 16 octets is simply 16 u8s.

Since Rust has support for 128 bit integers, you can also do (but be wary of endianness)

struct UUID(u128);

In the actual uuid crate, the former is done

1 Like

Ohkay. So if I implement malloc_size_of trait for UUID, it should return 0 in both the cases, right?

What's malloc_size_of from?

https://doc.servo.org/malloc_size_of/trait.MallocSizeOf.html

Yes, it should return 0

Okay. Thanks!