pub struct VmfFile {
pub path: Option<String>,
pub versioninfo: VersionInfo,
pub visgroups: VisGroups,
pub viewsettings: ViewSettings,
pub world: World,
pub entities: Entities,
pub hiddens: Entities,
pub cameras: Cameras,
pub cordons: Cordons,
}Expand description
Represents a parsed VMF file.
Fields§
§path: Option<String>The path to the VMF file, if known.
versioninfo: VersionInfoThe version info of the VMF file.
visgroups: VisGroupsThe visgroups in the VMF file.
viewsettings: ViewSettingsThe view settings in the VMF file.
world: WorldThe world data in the VMF file.
entities: EntitiesThe entities in the VMF file.
The hidden entities in the VMF file.
cameras: CamerasThe camera data in the VMF file.
cordons: CordonsThe cordon data in the VMF file.
Implementations§
Source§impl VmfFile
impl VmfFile
Sourcepub fn parse(content: &str) -> VmfResult<Self>
pub fn parse(content: &str) -> VmfResult<Self>
Parses a VMF file from a string.
§Arguments
content- The string content of the VMF file.
§Returns
A VmfResult containing the parsed VmfFile or a VmfError if parsing fails.
§Examples
use vmf_forge::VmfFile;
let vmf_content = r#"
versioninfo
{
"editorversion" "400"
"editorbuild" "8000"
"mapversion" "1"
"formatversion" "100"
"prefab" "0"
}
"#;
let vmf_file = VmfFile::parse(vmf_content);
assert!(vmf_file.is_ok());Sourcepub fn parse_file(file: &mut impl Read) -> VmfResult<Self>
pub fn parse_file(file: &mut impl Read) -> VmfResult<Self>
Parses a VMF file from a File.
§Arguments
file- TheFileto read from.
§Returns
A VmfResult containing the parsed VmfFile or a VmfError if parsing fails.
§Examples
use vmf_forge::VmfFile;
use std::fs::File;
let mut file = File::open("your_map.vmf").unwrap();
let vmf_file = VmfFile::parse_file(&mut file);
assert!(vmf_file.is_ok());Sourcepub fn save(&self, path: impl AsRef<Path>) -> VmfResult<()>
pub fn save(&self, path: impl AsRef<Path>) -> VmfResult<()>
Saves the VmfFile to a file at the specified path.
§Arguments
path- The path to save the VMF file to.
§Returns
A VmfResult indicating success or a VmfError if an error occurs.
§Examples
use vmf_forge::VmfFile;
let vmf_file = VmfFile::open("your_map.vmf").unwrap();
let result = vmf_file.save("new_map.vmf");
assert!(result.is_ok());Sourcepub fn merge(&mut self, other: VmfFile)
pub fn merge(&mut self, other: VmfFile)
Merges the contents of another VmfFile into this one.
This method combines the visgroups, world solids (both visible and hidden),
entities, hiddens, and cordons from the other VmfFile into the
current VmfFile. versioninfo, viewsettings, and cameras are
not merged; the original values in self are retained.
This method is experimental and its behavior may change in future versions. It does not handle potential ID conflicts between the two VMF files.
§Arguments
other- TheVmfFileto merge into this one.
§Example
use vmf_forge::prelude::*;
let mut vmf1 = VmfFile::open("map1.vmf").unwrap();
let vmf2 = VmfFile::open("map2.vmf").unwrap();
vmf1.merge(vmf2);
// vmf1 now contains the combined contents of both files.Sourcepub fn to_vmf_string(&self) -> String
pub fn to_vmf_string(&self) -> String
Converts the VmfFile to a string in VMF format.
§Returns
A string representing the VmfFile in VMF format.