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 File) -> VmfResult<Self>
pub fn parse_file(file: &mut File) -> 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 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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for VmfFile
impl<'de> Deserialize<'de> for VmfFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for VmfFile
impl RefUnwindSafe for VmfFile
impl Send for VmfFile
impl Sync for VmfFile
impl Unpin for VmfFile
impl UnwindSafe for VmfFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more