plotnik_lib/ir/string_ref.rs
1//! String pool entry reference.
2//!
3//! Strings are stored in a single contiguous byte pool. `StringRef` points
4//! into that pool via byte offset (not element index).
5
6/// Reference to a string in the string pool.
7///
8/// Layout: 8 bytes, align 4.
9#[repr(C)]
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub struct StringRef {
12 /// Byte offset into string_bytes segment.
13 pub offset: u32,
14 /// Length of the string in bytes.
15 pub len: u16,
16 _pad: u16,
17}
18
19impl StringRef {
20 pub const fn new(offset: u32, len: u16) -> Self {
21 Self {
22 offset,
23 len,
24 _pad: 0,
25 }
26 }
27}
28
29// Compile-time size verification
30const _: () = assert!(size_of::<StringRef>() == 8);
31const _: () = assert!(align_of::<StringRef>() == 4);