I am using Legion and it has a struct defined like below, pub struct Entity(NonZeroU64);
When I visualize the entity in the debug window, it shows a value. However, I don't see a straight forward method to access it. Can you help in accessing the value?
I am expecting something like below, let val: u64 = entity;
Thanks @leudz. I have a function which is called for each entity. At the end of the function, I am inserting processed data into Sled. Since I want a unique key, I thought I will use the Entity.0 as the unique key so in other parts of the code, I can use this Entity.0 to fetch the processed data from Sled.
I directly tried sled.insert(entity, my_data) which didn't work as Sled is expecting &[u8]
If it is private, the library authors have deliberately chosen to not let users access that inner field.
Often this is done because the number is an internal implementation detail, and letting users read/modify it could cause them to write code that violates assumptions made by Legion.
I don't think we should be recommending to use transmute() to hack around privacy.
You would need to check the source code or documentation to see whether the UUIDs are deterministic. I think it should be fine as long as you use the same Canon instance for serializing all your entities.