mnk-vmf

Crates.iomnk-vmf
lib.rsmnk-vmf
version0.1.0
created_at2025-11-08 10:56:50.828022+00
updated_at2025-11-08 10:56:50.828022+00
descriptionA library for parsing Valve Map Format (VMF) files.
homepagehttps://github.com/TheMenko/mnk-vmf
repositoryhttps://github.com/TheMenko/mnk-vmf
max_upload_size
id1922761
size16,431,069
Menko (TheMenko)

documentation

README

VMF Parser

A high-performance parser for Valve Map Format (VMF) files written in Rust.

Overview

VMF (Valve Map Format) is a text-based file format used by Source Engine level editors like Hammer to store map data. This library provides a fast, memory-efficient parser.

Supported VMF Structures

  • Version information and metadata
  • World geometry (solids, brushes, sides)
  • Entities (point entities, brush entities)
  • Displacement surfaces (terrain)
  • Visibility groups
  • View settings
  • Cameras
  • Cordons

Usage

[dependencies]
mnk_vmf = "0.1.0"

Basic Example

use mnk_vmf::VMF;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open and parse a VMF file
    let vmf = VMF::open("map.vmf")?;
    let data = vmf.parse()?;

    // Iterate through parsed blocks
    for value in data {
        match value {
            VMFValue::World(world) => {
                println!("World contains {} solids", world.solids.len());
            }
            VMFValue::Entity(entity) => {
                println!("Entity: {:?}", entity.classname);
            }
            _ => {}
        }
    }

    Ok(())
}

Working with World Geometry

use mnk_vmf::{VMF, VMFValue};

let vmf = VMF::open("map.vmf")?;
let data = vmf.parse()?;

for value in data {
    if let VMFValue::World(world) = value {
        for solid in &world.solids {
            println!("Solid ID: {}", solid.id);
            for side in &solid.sides {
                println!("  Material: {}", side.material);
                println!("  Plane: {:?}", side.plane);
            }
        }
    }
}

Development

Building

cargo build --release

Testing

cargo test

note: This crate uses over 150 tests, and almost everything is covered.

Running Benchmarks

cargo bench

License

Licensed under either of

at your option.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Commit count: 0

cargo fmt