Skip to main content

Crate source_vmf

Crate source_vmf 

Source
Expand description

A library for parsing and manipulating Valve Map Format (VMF) files.

This library provides functionality to parse VMF files used in Source Engine games into Rust data structures, modify the data, and serialize it back into a VMF file.

§Example

use source_vmf::prelude::*;
use std::fs::File;

fn main() -> Result<(), VmfError> {
    let vmf_file = VmfFile::open("vmf_examples/your_map.vmf")?;

    println!("Map Version: {}", vmf_file.versioninfo.map_version);

    Ok(())
}

Re-exports§

pub use errors::VmfError;
pub use errors::VmfResult;
pub use parse_ctx::FromBlock;
pub use parse_ctx::ParseCtx;
pub use system::Flattened;
pub use system::Instance;
pub use system::VmfSystem;
pub use transform::Transform;
pub use vmf::EntId;
pub use vmf::EntityIndex;
pub use vmf::VmfFile;

Modules§

errors
This module defines the error types used in the VMF parser using thiserror.
parse_ctx
Parser context for recording non-fatal syntax warnings and defaults during VMF parsing.
parser
This module provides the VMF parser implementation using the source-kv library.
prelude
A prelude module that re-exports commonly used items from the source_vmf crate.
system
A map together with every VMF its func_instances pull in. It might be a bit of overkill, and I couldn’t come up with a cleaner API.. but having this functionality is still useful
transform
Placement of a func_instance: rotation by its angles, then translation by its origin
vmf
This module contains the core data structures for representing VMF files, including the World, Entity, Solid, and other related types. It also re-exports the submodules common, entities, metadata, regions, and world.

Structs§

Extras
Preserves unrecognized keys and nested blocks during parsing for lossless round-tripping.
VmfBlock
Represents a block in a VMF file, which can contain key-value pairs and other blocks.

Constants§

REPEATED_KEY_SEP
Internal delimiter used to store multiple values of repeated keys in a single map entry.

Traits§

VmfSerializable
A trait for types that can be serialized into a VMF string representation.

Functions§

join_repeated_key
Joins multiple values for a repeated key into a single string using REPEATED_KEY_SEP.
write_key_value
Writes key-value pairs, expanding values joined by REPEATED_KEY_SEP back into separate lines.