Expand description
Game-neutral parsing infrastructure for Valve Source 2 demo files.
The core crate owns the game-independent PBDEMS2 container, bit encodings, flattened serializers, entity state, string tables, and coordinate helpers. Game crates provide their generated protobuf types and select an entity decoding dialect.
The guide module explains the shared file structure, packet framing,
serializers, string tables, entities, adapter boundary, and playback flow.
§Example
Walk the outer command stream, decompressing each body in turn:
use pbdems2::demo::Demo;
let bytes = std::fs::read("match.dem")?;
let demo = Demo::new(&bytes)?;
let mut body = Vec::new();
for frame in demo.commands() {
let frame = frame?;
frame.decode_body(&mut body)?;
println!("tick {}, command {}", frame.header().tick, frame.header().cmd);
}Reading entity state needs a game crate’s generated protobuf types:
implement DemoAdapter to convert them into the neutral types in
entity, then drive it with DemoParser.
Re-exports§
pub use entity::Entity;pub use entity::PropertyFilter;pub use error::Error;pub use error::Result;pub use limits::DecodeLimits;pub use mmap::MappedDemo;mmappub use packet::PacketMessageFrame;pub use packet::PacketMessageIter;pub use playback::CheckpointAdapter;pub use playback::CommandContext;pub use playback::DemoAdapter;pub use playback::DemoParser;pub use playback::ParserState;pub use playback::PlaybackCheckpoint;pub use playback::PlaybackSegment;pub use playback::PlaybackSession;pub use playback::PreparedPlayback;
Modules§
- demo
- Game-independent PBDEMS2 command framing.
- entity
- Entity system for parsing and representing game state.
- error
- Error and result types shared by every fallible operation in the crate.
- guide
- PBDEMS2 format and parser architecture guide.
- io
- I/O utilities for reading demo file data.
- limits
- Resource limits used while decoding untrusted demo data.
- mmap
mmap - Optional owning memory-mapped demo input.
- packet
- Game-neutral framing for messages carried inside Source 2 packets.
- playback
- Protobuf-independent demo initialization, seeking, and tick playback.
- position
- World-coordinate helpers for Source 2’s split position storage.