source-vmt 0.3.0

Rust parser and manager for Source Engine VMT files, supporting patch inheritance, material proxies, and key interning
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use serde::de::DeserializeOwned;
use crate::vmt::Vmt;

impl Vmt {
    /// Deserializes a specific block into a Serde-compatible struct.
    pub fn get_block<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>, source_kv::Error> {
        if let Some(val) = self.get_raw(key) {
            let parsed: T = source_kv::from_value(val.clone())?;
            return Ok(Some(parsed));
        }
        Ok(None)
    }
}