gudenau on Nostr: How on earth am I supposed to have a static read only list of structures that ...
How on earth am I supposed to have a static read only list of structures that contains read only opaque C pointers?
I have something akin to
```Rust
#[repr(C)]
pub struct Handle {
_data: [u8; 0],
_marker: PhantomData<...>,
}
struct State {
handle: Handle,
}
static STATE : OnceLock<Vec<State>> = OnceLock::new();
```
and I can't figure out what combination of locks/traits I need to make this "thread safe" even though it's 99% read-only.
Published at
2025-03-27 21:37:48 UTCEvent JSON
{
"id": "3f04cff031d0d3cc8062a0364933c6476844fb62796ea42ffceb8c72af089a65",
"pubkey": "db46a46e48fbb369dac7db115ec93ac88b3fd141eade8a6ba3e8e94e54ef0e9f",
"created_at": 1743111468,
"kind": 1,
"tags": [
[
"content-warning",
"Rust Help, Screen Reader Unfriendly"
],
[
"proxy",
"https://fosstodon.org/@gudenau/114236553183939915",
"web"
],
[
"proxy",
"https://fosstodon.org/users/gudenau/statuses/114236553183939915",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://fosstodon.org/users/gudenau/statuses/114236553183939915",
"pink.momostr"
],
[
"-"
]
],
"content": "How on earth am I supposed to have a static read only list of structures that contains read only opaque C pointers?\n\nI have something akin to\n```Rust\n#[repr(C)] \npub struct Handle {\n _data: [u8; 0],\n _marker: PhantomData\u003c...\u003e,\n}\n\nstruct State {\n handle: Handle,\n}\n\nstatic STATE : OnceLock\u003cVec\u003cState\u003e\u003e = OnceLock::new();\n```\n\nand I can't figure out what combination of locks/traits I need to make this \"thread safe\" even though it's 99% read-only.",
"sig": "7e8c9abfb6f8c3e6f01673cb0d4a8dab226fbff0e2bde9e88f312f4acb952b33dbcfda720e23071f30849ea18dd29f8df675e9b2bf5a4d52bf9cf8ea4d135a66"
}