StringTape
A memory-efficient string storage library compatible with Apache Arrow's string array format.
Stores multiple strings in a contiguous memory layout using offset-based indexing, similar to Arrow's String
and LargeString
arrays.
- Apache Arrow Compatible: Matching
String
andLargeString
arrays - Memory Efficient: All strings stored in two contiguous buffers
- Zero-Copy Views: Efficient slicing with
[i..n]
range syntax - Zero Dependencies: Pure Rust implementation, with
no_std
support
Quick Start
use ;
// Create a new StringTape with 32-bit offsets
let mut tape = new;
tape.push?;
tape.push?;
assert_eq!;
assert_eq!;
assert_eq!;
// Iterate over strings
for s in &tape
// Build from iterator
let tape2: StringTape32 = .into_iter.collect;
assert_eq!;
# Ok::
Memory Layout
StringTape uses the same memory layout as Apache Arrow string arrays:
Data buffer: [h,e,l,l,o,w,o,r,l,d]
Offset buffer: [0, 5, 10]
API Overview
Basic Operations
use StringTape32;
let mut tape = new;
tape.push?; // Append one string
tape.extend?; // Append an array
assert_eq!; // Direct indexing
assert_eq!; // Safe access
for s in &tape
// Construct from an iterator
let tape2: StringTape32 = .into_iter.collect;
Views and Slicing
let view = tape.view; // View entire tape
let subview = tape.subview?; // Items [1, 3)
let nested = subview.subview?; // Nested subviews
let raw_bytes = &tape.view; // Raw byte slice
// Views have same API as tapes
assert_eq!;
assert_eq!;
Memory Management
// Pre-allocate capacity
let tape = with_capacity?; // 1KB data, 100 strings
// Monitor usage
println!;
// Modify
tape.clear; // Remove all items
tape.truncate; // Keep first 5 items
// Custom allocators
use Global;
let tape = new_in;
Apache Arrow Interop
True zero-copy conversion to/from Arrow arrays:
// StringTape → Arrow (zero-copy)
let = tape.arrow_slices;
let data_buffer = from_slice_ref;
let offsets_buffer = new;
let arrow_array = new;
// Arrow → StringTapeView (zero-copy)
let view = unsafe ;
no_std
Support
StringTape can be used in no_std
environments:
[]
= { = "0.1", = false }
In no_std
mode:
- All functionality is preserved
- Requires
alloc
for dynamic allocation - Error types implement
Display
but notstd::error::Error
Testing
Run tests for both std
and no_std
configurations: