Expand description
Decoder for the RunAndRecord RecordBatch columns blob.
Turns the opaque little-endian batch blob into structured vehicles and
traffic light signals so SDK users do not reimplement the binary parsing.
This module is always available and does not require the server feature).
Decoder for the RecordBatch columns blob.
RunAndRecord streams batches of simulation state as an opaque little-endian
byte blob in the RecordBatch.columns field. This module turns that blob into
the SAME proto/gRPC types that the live simulation_step_session RPC
returns, so replaying a recording yields identical types to live stepping.
The authoritative blob layout (version 1) is produced by the server in src/server/record.rs (BatchAcc::to_blob) and documented in protos/record.proto. All integers are little-endian.
USAGE
use micro_traffic_sim::record::decode_record_batch;
fn handle(columns: &[u8]) -> Result<(), Box<dyn std::error::Error>> {
let responses = decode_record_batch(columns)?;
for resp in &responses {
for v in &resp.vehicle_data {
println!("tick {} vehicle {} at cell {}", resp.timestamp, v.vehicle_id, v.cell);
}
for tls in &resp.tls_data {
for group in &tls.groups {
println!("tick {} tl {} group {} signal {}", resp.timestamp, tls.id, group.id, group.signal);
}
}
}
Ok(())
}Enums§
- Decode
Error - Reasons decoding a RecordBatch columns blob can fail.
Functions§
- decode_
record_ batch - Decode a RecordBatch columns blob into per-tick proto SessionStepResponse values, one element per tick in the batch.