aion-context 1.0.0

Cryptographically-signed, versioned business-context file format
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
// SPDX-License-Identifier: MIT OR Apache-2.0
//! String table for AION v2 file format
//!
//! This module implements the null-terminated UTF-8 string table as specified
//! in RFC-0002 Section 5.5. The string table is used to store variable-length
//! text data such as commit messages, audit details, and metadata.
//!
//! # Format
//!
//! The string table is a concatenation of null-terminated UTF-8 strings with
//! no padding between entries:
//!
//! ```text
//! "Genesis version\0Added fraud detection\0Updated rules\0"
//! ```
//!
//! # Rules (RFC-0002)
//!
//! 1. All strings are UTF-8 encoded
//! 2. Each string terminated with single null byte (0x00)
//! 3. No padding between strings
//! 4. Offsets point to first character (not null terminator)
//! 5. Lengths do NOT include null terminator
//!
//! # Building String Tables
//!
//! Use [`StringTableBuilder`] to construct string tables during serialization:
//!
//! ```
//! use aion_context::string_table::StringTableBuilder;
//!
//! let mut builder = StringTableBuilder::new();
//!
//! // Add strings and get their (offset, length)
//! let (offset1, len1) = builder.add("Genesis version");
//! let (offset2, len2) = builder.add("Added fraud detection");
//!
//! // Build final byte array
//! let bytes = builder.build();
//!
//! assert_eq!(offset1, 0);
//! assert_eq!(len1, 15);
//! assert_eq!(offset2, 16); // "Genesis version\0" = 16 bytes
//! assert_eq!(len2, 21);
//! ```
//!
//! # Parsing String Tables
//!
//! Use [`StringTable`] for zero-copy parsing during deserialization:
//!
//! ```
//! use aion_context::string_table::StringTable;
//!
//! let data = b"Genesis version\0Added fraud detection\0";
//! let table = StringTable::new(data).unwrap();
//!
//! // Extract strings by offset/length
//! let s1 = table.get(0, 15).unwrap();
//! assert_eq!(s1, "Genesis version");
//!
//! let s2 = table.get(16, 21).unwrap();
//! assert_eq!(s2, "Added fraud detection");
//! ```
//!
//! # UTF-8 Validation
//!
//! All strings are validated as UTF-8:
//! - During construction (when added to builder)
//! - During parsing (when table is created)
//! - During extraction (when strings are retrieved)
//!
//! Invalid UTF-8 sequences return [`AionError::InvalidUtf8`].

use crate::{AionError, Result};

/// String table builder for constructing string tables during serialization
///
/// This builder accumulates strings and tracks their offsets/lengths.
/// Strings are automatically null-terminated and concatenated with no padding.
///
/// # Examples
///
/// ```
/// use aion_context::string_table::StringTableBuilder;
///
/// let mut builder = StringTableBuilder::new();
///
/// let (offset, length) = builder.add("Hello, world!");
/// assert_eq!(offset, 0);
/// assert_eq!(length, 13);
///
/// let bytes = builder.build();
/// assert_eq!(bytes, b"Hello, world!\0");
/// ```
#[derive(Debug, Clone, Default)]
pub struct StringTableBuilder {
    /// Accumulated string data (null-terminated)
    data: Vec<u8>,
}

impl StringTableBuilder {
    /// Create a new empty string table builder
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let builder = StringTableBuilder::new();
    /// assert_eq!(builder.len(), 0);
    /// assert!(builder.is_empty());
    /// ```
    #[must_use]
    #[allow(clippy::missing_const_for_fn)] // Vec::new() not const in MSRV 1.70
    pub fn new() -> Self {
        Self { data: Vec::new() }
    }

    /// Create a builder with pre-allocated capacity
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let builder = StringTableBuilder::with_capacity(1024);
    /// assert_eq!(builder.len(), 0);
    /// ```
    #[must_use]
    pub fn with_capacity(capacity: usize) -> Self {
        Self {
            data: Vec::with_capacity(capacity),
        }
    }

    /// Add a string to the table
    ///
    /// Returns `(offset, length)` where:
    /// - `offset` is the byte offset of the string's first character
    /// - `length` is the string length in bytes (excluding null terminator)
    ///
    /// The string is automatically null-terminated and appended to the table.
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let mut builder = StringTableBuilder::new();
    ///
    /// let (offset1, len1) = builder.add("First");
    /// assert_eq!(offset1, 0);
    /// assert_eq!(len1, 5);
    ///
    /// let (offset2, len2) = builder.add("Second");
    /// assert_eq!(offset2, 6); // "First\0" = 6 bytes
    /// assert_eq!(len2, 6);
    /// ```
    #[allow(clippy::cast_possible_truncation)] // String lengths capped by u32::MAX
    pub fn add(&mut self, s: &str) -> (u64, u32) {
        let offset = self.data.len() as u64;
        let length = s.len() as u32;

        // Append string bytes
        self.data.extend_from_slice(s.as_bytes());

        // Append null terminator
        self.data.push(0);

        (offset, length)
    }

    /// Get the current total size in bytes
    ///
    /// This includes all strings and their null terminators.
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let mut builder = StringTableBuilder::new();
    /// assert_eq!(builder.len(), 0);
    ///
    /// builder.add("Hello");
    /// assert_eq!(builder.len(), 6); // "Hello\0"
    ///
    /// builder.add("World");
    /// assert_eq!(builder.len(), 12); // "Hello\0World\0"
    /// ```
    #[must_use]
    pub fn len(&self) -> usize {
        self.data.len()
    }

    /// Check if the table is empty
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let mut builder = StringTableBuilder::new();
    /// assert!(builder.is_empty());
    ///
    /// builder.add("Test");
    /// assert!(!builder.is_empty());
    /// ```
    #[must_use]
    pub fn is_empty(&self) -> bool {
        self.data.is_empty()
    }

    /// Build the final string table as a byte vector
    ///
    /// Returns the complete string table with all null terminators.
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let mut builder = StringTableBuilder::new();
    /// builder.add("Alpha");
    /// builder.add("Beta");
    ///
    /// let bytes = builder.build();
    /// assert_eq!(bytes, b"Alpha\0Beta\0");
    /// ```
    #[must_use]
    pub fn build(self) -> Vec<u8> {
        self.data
    }

    /// Clear all strings from the builder
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTableBuilder;
    ///
    /// let mut builder = StringTableBuilder::new();
    /// builder.add("Test");
    /// assert!(!builder.is_empty());
    ///
    /// builder.clear();
    /// assert!(builder.is_empty());
    /// ```
    pub fn clear(&mut self) {
        self.data.clear();
    }
}

/// String table for zero-copy parsing of string data
///
/// This struct wraps a byte slice containing null-terminated UTF-8 strings.
/// Strings can be extracted by offset and length without copying.
///
/// # Examples
///
/// ```
/// use aion_context::string_table::StringTable;
///
/// let data = b"Genesis\0Version 2\0";
/// let table = StringTable::new(data).unwrap();
///
/// let s1 = table.get(0, 7).unwrap();
/// assert_eq!(s1, "Genesis");
///
/// let s2 = table.get(8, 9).unwrap();
/// assert_eq!(s2, "Version 2");
/// ```
#[derive(Debug, Clone, Copy)]
pub struct StringTable<'a> {
    /// Raw byte data containing null-terminated strings
    data: &'a [u8],
}

impl<'a> StringTable<'a> {
    /// Create a new string table from byte data
    ///
    /// # Errors
    ///
    /// Returns an error if:
    /// - The data contains invalid UTF-8 sequences
    /// - The data is not properly null-terminated
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTable;
    ///
    /// let data = b"Hello\0World\0";
    /// let table = StringTable::new(data).unwrap();
    /// ```
    pub fn new(data: &'a [u8]) -> Result<Self> {
        // Validate that data contains valid UTF-8
        // We do this by attempting to convert to str
        std::str::from_utf8(data).map_err(|e| AionError::InvalidUtf8 {
            reason: format!("String table contains invalid UTF-8: {e}"),
        })?;

        Ok(Self { data })
    }

    /// Get a string by offset and length
    ///
    /// # Arguments
    ///
    /// * `offset` - Byte offset to the first character of the string
    /// * `length` - Length of the string in bytes (excluding null terminator)
    ///
    /// # Errors
    ///
    /// Returns an error if:
    /// - Offset + length exceeds table bounds
    /// - The extracted bytes are not valid UTF-8
    /// - The string is not properly null-terminated
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTable;
    ///
    /// let data = b"First\0Second\0Third\0";
    /// let table = StringTable::new(data).unwrap();
    ///
    /// assert_eq!(table.get(0, 5).unwrap(), "First");
    /// assert_eq!(table.get(6, 6).unwrap(), "Second");
    /// assert_eq!(table.get(13, 5).unwrap(), "Third");
    /// ```
    #[allow(clippy::cast_possible_truncation)] // u64 to usize for indexing
    pub fn get(&self, offset: u64, length: u32) -> Result<&'a str> {
        let offset = offset as usize;
        let length = length as usize;

        // Check bounds
        let end = offset
            .checked_add(length)
            .ok_or_else(|| AionError::InvalidFormat {
                reason: format!("String table access overflow: offset={offset}, length={length}"),
            })?;

        if end > self.data.len() {
            return Err(AionError::InvalidFormat {
                reason: format!(
                    "String table access out of bounds: offset={offset}, length={length}, table_size={}",
                    self.data.len()
                ),
            });
        }

        // Extract string bytes (excluding null terminator)
        let string_bytes = self
            .data
            .get(offset..end)
            .ok_or_else(|| AionError::InvalidFormat {
                reason: format!("Failed to extract string at offset {offset}"),
            })?;

        // Verify null terminator is present
        if end < self.data.len() {
            if let Some(&byte) = self.data.get(end) {
                if byte != 0 {
                    return Err(AionError::InvalidFormat {
                        reason: format!("String at offset {offset} is not null-terminated"),
                    });
                }
            }
        }

        // Convert to UTF-8 string
        std::str::from_utf8(string_bytes).map_err(|e| AionError::InvalidUtf8 {
            reason: format!("String at offset {offset} contains invalid UTF-8: {e}"),
        })
    }

    /// Get total size of the string table in bytes
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTable;
    ///
    /// let data = b"Alpha\0Beta\0";
    /// let table = StringTable::new(data).unwrap();
    /// assert_eq!(table.len(), 11);
    /// ```
    #[must_use]
    pub const fn len(&self) -> usize {
        self.data.len()
    }

    /// Check if the string table is empty
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTable;
    ///
    /// let empty = StringTable::new(b"").unwrap();
    /// assert!(empty.is_empty());
    ///
    /// let non_empty = StringTable::new(b"Test\0").unwrap();
    /// assert!(!non_empty.is_empty());
    /// ```
    #[must_use]
    pub const fn is_empty(&self) -> bool {
        self.data.is_empty()
    }

    /// Get the raw byte data
    ///
    /// # Examples
    ///
    /// ```
    /// use aion_context::string_table::StringTable;
    ///
    /// let data = b"Hello\0";
    /// let table = StringTable::new(data).unwrap();
    /// assert_eq!(table.as_bytes(), b"Hello\0");
    /// ```
    #[must_use]
    pub const fn as_bytes(&self) -> &'a [u8] {
        self.data
    }
}

#[cfg(test)]
#[allow(clippy::unwrap_used)] // Allow unwrap in test code
mod tests {
    use super::*;

    mod builder {
        use super::*;

        #[test]
        fn should_create_empty_builder() {
            let builder = StringTableBuilder::new();
            assert_eq!(builder.len(), 0);
            assert!(builder.is_empty());
        }

        #[test]
        fn should_add_single_string() {
            let mut builder = StringTableBuilder::new();
            let (offset, length) = builder.add("Hello");

            assert_eq!(offset, 0);
            assert_eq!(length, 5);
            assert_eq!(builder.len(), 6); // "Hello\0"

            let bytes = builder.build();
            assert_eq!(bytes, b"Hello\0");
        }

        #[test]
        fn should_add_multiple_strings() {
            let mut builder = StringTableBuilder::new();

            let (offset1, len1) = builder.add("First");
            assert_eq!(offset1, 0);
            assert_eq!(len1, 5);

            let (offset2, len2) = builder.add("Second");
            assert_eq!(offset2, 6);
            assert_eq!(len2, 6);

            let (offset3, len3) = builder.add("Third");
            assert_eq!(offset3, 13);
            assert_eq!(len3, 5);

            let bytes = builder.build();
            assert_eq!(bytes, b"First\0Second\0Third\0");
        }

        #[test]
        fn should_handle_empty_strings() {
            let mut builder = StringTableBuilder::new();
            let (offset, length) = builder.add("");

            assert_eq!(offset, 0);
            assert_eq!(length, 0);
            assert_eq!(builder.len(), 1); // Just null terminator

            let bytes = builder.build();
            assert_eq!(bytes, b"\0");
        }

        #[test]
        fn should_handle_utf8_strings() {
            let mut builder = StringTableBuilder::new();

            builder.add("Hello 世界");
            builder.add("Γειά σου κόσμε");
            builder.add("🎉🎊");

            let bytes = builder.build();
            let expected = "Hello 世界\0Γειά σου κόσμε\0🎉🎊\0";
            assert_eq!(bytes, expected.as_bytes());
        }

        #[test]
        fn should_handle_special_characters() {
            let mut builder = StringTableBuilder::new();
            builder.add("Line1\nLine2");
            builder.add("Tab\there");
            builder.add("Quote\"Test");

            let bytes = builder.build();
            assert_eq!(bytes, b"Line1\nLine2\0Tab\there\0Quote\"Test\0");
        }

        #[test]
        fn should_create_with_capacity() {
            let builder = StringTableBuilder::with_capacity(1024);
            assert_eq!(builder.len(), 0);
            assert!(builder.is_empty());
        }

        #[test]
        fn should_clear_builder() {
            let mut builder = StringTableBuilder::new();
            builder.add("Test");
            assert_eq!(builder.len(), 5);

            builder.clear();
            assert_eq!(builder.len(), 0);
            assert!(builder.is_empty());
        }

        #[test]
        fn should_track_offsets_correctly() {
            let mut builder = StringTableBuilder::new();

            let strings = vec![
                "Genesis version",
                "Added fraud detection",
                "Updated compliance rules",
            ];

            let mut expected_offset = 0u64;
            for s in &strings {
                let (offset, length) = builder.add(s);
                assert_eq!(offset, expected_offset);
                assert_eq!(length as usize, s.len());
                expected_offset += s.len() as u64 + 1; // +1 for null terminator
            }
        }
    }

    mod parser {
        use super::*;

        #[test]
        fn should_parse_empty_table() {
            let table = StringTable::new(b"").unwrap();
            assert_eq!(table.len(), 0);
            assert!(table.is_empty());
        }

        #[test]
        fn should_parse_single_string() {
            let data = b"Hello\0";
            let table = StringTable::new(data).unwrap();

            let s = table.get(0, 5).unwrap();
            assert_eq!(s, "Hello");
        }

        #[test]
        fn should_parse_multiple_strings() {
            let data = b"First\0Second\0Third\0";
            let table = StringTable::new(data).unwrap();

            assert_eq!(table.get(0, 5).unwrap(), "First");
            assert_eq!(table.get(6, 6).unwrap(), "Second");
            assert_eq!(table.get(13, 5).unwrap(), "Third");
        }

        #[test]
        fn should_handle_empty_string() {
            let data = b"\0Test\0";
            let table = StringTable::new(data).unwrap();

            assert_eq!(table.get(0, 0).unwrap(), "");
            assert_eq!(table.get(1, 4).unwrap(), "Test");
        }

        #[test]
        fn should_parse_utf8_strings() {
            let s1 = "Hello 世界";
            let s2 = "🎉";
            let data = format!("{s1}\0{s2}\0");
            let table = StringTable::new(data.as_bytes()).unwrap();

            #[allow(clippy::cast_possible_truncation)]
            let len1 = s1.len() as u32;
            #[allow(clippy::cast_possible_truncation)]
            let len2 = s2.len() as u32;
            let offset2 = u64::from(len1 + 1); // +1 for null terminator

            assert_eq!(table.get(0, len1).unwrap(), s1);
            assert_eq!(table.get(offset2, len2).unwrap(), s2);
        }

        #[test]
        fn should_reject_invalid_utf8() {
            let data = b"Hello\0\xFF\xFE\0"; // Invalid UTF-8
            let result = StringTable::new(data);
            assert!(result.is_err());
        }

        #[test]
        fn should_reject_out_of_bounds_access() {
            let data = b"Test\0";
            let table = StringTable::new(data).unwrap();

            // Offset beyond bounds
            let result = table.get(100, 5);
            assert!(result.is_err());

            // Length exceeds bounds
            let result = table.get(0, 100);
            assert!(result.is_err());
        }

        #[test]
        fn should_verify_null_terminator() {
            let data = b"Hello\0World\0";
            let table = StringTable::new(data).unwrap();

            // Valid: properly null-terminated
            assert!(table.get(0, 5).is_ok());

            // Invalid: wrong length (would miss null terminator)
            let result = table.get(0, 10);
            assert!(result.is_err());
        }

        #[test]
        fn should_get_as_bytes() {
            let data = b"Test\0";
            let table = StringTable::new(data).unwrap();
            assert_eq!(table.as_bytes(), b"Test\0");
        }
    }

    mod roundtrip {
        use super::*;

        #[test]
        fn should_roundtrip_single_string() {
            let mut builder = StringTableBuilder::new();
            let (offset, length) = builder.add("Test string");

            let bytes = builder.build();
            let table = StringTable::new(&bytes).unwrap();

            let recovered = table.get(offset, length).unwrap();
            assert_eq!(recovered, "Test string");
        }

        #[test]
        fn should_roundtrip_multiple_strings() {
            let mut builder = StringTableBuilder::new();

            let strings = vec![
                "Genesis version",
                "Added fraud detection",
                "Updated compliance rules",
                "Fixed security vulnerability",
            ];

            let mut entries = Vec::new();
            for s in &strings {
                entries.push(builder.add(s));
            }

            let bytes = builder.build();
            let table = StringTable::new(&bytes).unwrap();

            for ((offset, length), expected) in entries.iter().zip(&strings) {
                let recovered = table.get(*offset, *length).unwrap();
                assert_eq!(recovered, *expected);
            }
        }

        #[test]
        fn should_roundtrip_utf8() {
            let mut builder = StringTableBuilder::new();

            let strings = vec!["Hello 世界", "Γειά σου κόσμε", "مرحبا بالعالم", "🎉🎊🎈"];

            let mut entries = Vec::new();
            for s in &strings {
                entries.push(builder.add(s));
            }

            let bytes = builder.build();
            let table = StringTable::new(&bytes).unwrap();

            for ((offset, length), expected) in entries.iter().zip(&strings) {
                let recovered = table.get(*offset, *length).unwrap();
                assert_eq!(recovered, *expected);
            }
        }

        #[test]
        fn should_roundtrip_empty_string() {
            let mut builder = StringTableBuilder::new();
            let (offset, length) = builder.add("");

            let bytes = builder.build();
            let table = StringTable::new(&bytes).unwrap();

            let recovered = table.get(offset, length).unwrap();
            assert_eq!(recovered, "");
        }
    }

    mod properties {
        use super::*;
        use hegel::generators as gs;

        #[hegel::test]
        fn prop_add_get_roundtrip(tc: hegel::TestCase) {
            let strings = tc.draw(gs::vecs(gs::text().max_size(64)).min_size(1).max_size(16));
            let mut builder = StringTableBuilder::new();
            let handles: Vec<(u64, u32)> = strings.iter().map(|s| builder.add(s)).collect();
            let bytes = builder.build();
            let table = StringTable::new(&bytes).unwrap_or_else(|_| std::process::abort());
            for (original, (offset, length)) in strings.iter().zip(handles.iter()) {
                let recovered = table
                    .get(*offset, *length)
                    .unwrap_or_else(|_| std::process::abort());
                assert_eq!(recovered, original.as_str());
            }
        }

        #[hegel::test]
        fn prop_builder_len_strictly_increases_on_add(tc: hegel::TestCase) {
            let strings = tc.draw(gs::vecs(gs::text().max_size(64)).min_size(1).max_size(16));
            let mut builder = StringTableBuilder::new();
            let mut prev = builder.len();
            for s in &strings {
                builder.add(s);
                let now = builder.len();
                assert!(now > prev);
                prev = now;
            }
        }
    }
}