#file-format #valve #dmx #binary-format #serialization #deserialize #binary-encoding

datamodel

A rust library to serialize and deserialize Valve's proprietary DMX file format

8 releases (4 breaking)

0.6.1 Oct 2, 2024
0.6.0 Oct 2, 2024
0.5.3 Mar 4, 2024
0.5.1 Jan 24, 2024
0.1.0 Nov 3, 2023

#1713 in Parser implementations

MIT license

130KB
2.5K SLoC

datamodel-rs

datamodel-rs is a Rust library that provides functionality to serialize and deserialize Valve’s proprietary DMX file format.

What is DMX?

DMX is a file format created by Valve Corporation to store data in a key-value format. It is primarily used for Source Filmmaker (SFM), but it can also be used for other purposes such as 3D models and particles. DMX files can be saved in either text or binary format. DMX is similar to XML in that it uses elements and attributes to store data.

What is supported?

  • Binary encoding version 1 - 5 supported
  • keyvalues2 encoding
  • keyvalues2_flat encoding

What is needed?

  • legacy xml encoding
  • Documentation

lib.rs:

Data Model

Example

use datamodel::{
    serializers::KeyValues2Serializer,
    Element,
    Header,
    Serializer
};

let mut root = Element::named("root");
root.set_value("The Value", 84);
root.set_value("The Size", 0.4);

let file = std::fs::File::create("example.dmx").unwrap();
let mut writer = std::io::BufWriter::new(file);
let _ = KeyValues2Serializer::serialize(&mut writer, &Header::default(), &root);

Dependencies

~3.5–5.5MB
~98K SLoC