# memory-safe-parser
Zero-copy parsing for semi-structured **log-like** text in Rust:
- stream **lines** over `&str`/`&[u8]` or a **memory-mapped** file;
- **`&str`** field views into the original line (no per-token heap strings);
- optional **`bumpalo`** arena for a small **per-line AST** when you want structured pointers without a global allocator party.
Licensed under **MIT OR Apache-2.0**.
## Crate name vs import name
Cargo dependency:
```toml
memory-safe-parser = "0.1"
```
Rust import:
```rust
use memory_safe_parser::{LogDialect, MappedFile};
```
Docs on [docs.rs](https://docs.rs/memory-safe-parser) after the first publish.
## Quickstart
Run the mmap example against bundled sample data:
```bash
cargo run --example mmap_stream
```
Parse an in-memory string without mmap:
```rust
use memory_safe_parser::{parse_log_stream, LogDialect};
let dialect = LogDialect::default();
for record in parse_log_stream("lvl=INFO msg=hello\n", dialect, None) {
let record = record?;
// record.line.text, record.fields[..]
}
```
## Before publishing to crates.io
1. Confirm the crate **`name`** is still free on [crates.io](https://crates.io/crates/memory-safe-parser).
2. Replace **`authors`** / **`repository`** in `Cargo.toml` if your Git repo URL or contact details differ.
3. Dry run:
```bash
cargo publish --dry-run
```
4. Publish:
```bash
cargo publish
```
See also the mmap safety notes in the `MappedFile` documentation in source.