ngdp-bpsv
A Rust parser and writer for BPSV (Blizzard Pipe-Separated Values) format, used throughout Blizzard's NGDP (Next Generation Distribution Pipeline) system.
Overview
BPSV is a structured data format used by Blizzard Entertainment across their content delivery network. It features:
- 📊 Typed columns (STRING, HEX, DEC)
- 🔢 Sequence numbers for version tracking
- 📋 Pipe-separated values with header definitions
- ✅ Built-in validation for data types and constraints
Installation
Add this to your Cargo.toml:
[]
= "0.3"
Quick Start
Parsing BPSV Data
use BpsvDocument;
let data = r#"Region!STRING:0|BuildId!DEC:4|Hash!HEX:32
## seqn = 12345
us|1234|deadbeefcafebabedeadbeefcafebabe
eu|5678|1234567890abcdef1234567890abcdef"#;
let doc = parse?;
println!;
println!;
Building BPSV Data
use ;
let mut builder = new;
builder.add_field?;
builder.add_field?;
builder.set_sequence_number;
builder.add_row?;
let output = builder.build?;
Format Specification
Field Types
- STRING:length - String field (length 0 = unlimited)
- HEX:length - Hexadecimal field (length in bytes, N bytes = N*2 hex chars)
- DEC:length - Decimal integer field
Structure
FieldName!TYPE:length|AnotherField!TYPE:length
## seqn = 12345
value1|value2
value3|value4
Examples
Parse Ribbit Version Data
use BpsvDocument;
let versions_data = read_to_string?;
let doc = parse?;
// Find all US region entries
let us_rows = doc.find_rows_by_field?;
for row_idx in us_rows
Type-Safe Value Access
// Access typed values from a row
let row = &doc.rows;
let schema = doc.schema;
// Get raw string value
let region = row.get_raw_by_name.unwrap;
// Get typed value (requires mutable row)
let mut row = doc.rows.clone;
let typed_values = row.get_typed_values?;
if let Decimal = &typed_values
Build CDN Configuration
use ;
let mut builder = new;
builder.add_field?;
builder.add_field?;
builder.add_field?;
builder.set_sequence_number;
builder.add_row?;
println!;
Features
- 🚀 Fast parsing with minimal allocations
- 🔍 Type validation and error reporting
- 🏗️ Builder pattern for document creation
- 📝 Round-trip compatibility (parse → build → parse)
- 🔧 Case-insensitive field type parsing
- 📭 Empty value support for all field types
Error Handling
The library provides detailed error types for common issues:
use ;
match parse
Performance
The parser is optimized for the typical BPSV use cases:
- Small to medium documents (< 10,000 rows)
- Fast field lookups via schema indexing
- Lazy type parsing (on-demand conversion)
See the benchmarks for detailed performance metrics.
📄 License
This project is dual-licensed under either:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
🫶 Acknowledgments
This crate is part of the cascette-rs project, providing tools for World of Warcraft
emulation development.