| Crates.io | zcstring |
| lib.rs | zcstring |
| version | 0.1.0 |
| created_at | 2026-01-25 20:43:55.206511+00 |
| updated_at | 2026-01-25 20:43:55.206511+00 |
| description | High-performance zero-copy string handles for Serde, backed by arcstr. |
| homepage | https://github.com/CyberNestSticks-LLC/zcstring.git |
| repository | https://github.com/CyberNestSticks-LLC/zcstring.git |
| max_upload_size | |
| id | 2069499 |
| size | 31,273 |
ZCString is a context-aware string wrapper for
arcstr::Substr designed for efficient, zero-copy
string management. It uses thread-local storage to track a "source"
string, allowing substrings to be derived from existing memory buffers
without triggering new allocations. The currently supported use
case is parsing of json strings with serde_json.
When parsing or processing large strings, you often want to derive
substrings that point back to the original memory. ZCString simplifies
this by:
Tracking Source Memory: It maintains a thread-local SOURCE reference that acts as the active memory context.
Identity-Based Slicing: When creating a string via
from_str_with_source, it checks if the pointer resides within the
current SOURCE. If it does, it returns a sub-slice; otherwise, it falls
back to a standard allocation.
Recursive Safety: It uses RAII guards to allow nesting of different source contexts, automatically restoring the previous source when a scope ends.
ArcStr.with_source
or get_source_guard.Add this to your Cargo.toml:
[dependencies]
# by default the std and serde features are enable
zcstring = "0.1.0"
## Example code
cargo run --example simple_example