Skip to main content

Vmt

Struct Vmt 

Source
pub struct Vmt {
    pub shader: String,
    pub properties: IndexMap<VmtKey, Vec<Value>>,
}

Fields§

§shader: String§properties: IndexMap<VmtKey, Vec<Value>>

Implementations§

Source§

impl Vmt

Source

pub fn new(shader: &str) -> Self

Creates a new empty VMT with the specified shader.

Source

pub fn from_str(input: &str) -> Result<Self, Error>

Parses VMT from a string using AST parser to handle root-level shader.

Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Parses VMT from a file.

Source

pub fn set_string(&mut self, key: &str, value: &str) -> &mut Self

Set a string property. Overwrites if exists.

Source

pub fn set_flag(&mut self, key: &str, enabled: bool) -> &mut Self

Set a flag (boolean) property (converts to “1” or “0”).

Source

pub fn remove(&mut self, key: &str) -> &mut Self

Removes a property by key, checking for $, % and raw name.

Source

pub fn get_raw(&self, key: &str) -> Option<&Value>

O(1) lookup. Handles $, % prefixes and case-insensitive keys.

Source

pub fn get_string(&self, key: &str) -> Option<String>

Get value as string if it exists.

Source

pub fn get_f32(&self, key: &str) -> Option<f32>

Safely gets a value and parses it as f32.

Source

pub fn get_i32(&self, key: &str) -> Option<i32>

Safely gets a value and parses it as i32.

Source

pub fn get_bool(&self, key: &str) -> bool

Checks boolean flags: supports “1”, “true”, “yes”.

Source

pub fn get_color(&self, key: &str) -> Option<[f32; 3]>

Parses colors/vectors in both [0.0 0.0 0.0] and {255 255 255} formats. Returns a normalized [f32; 3] (0.0 to 1.0).

Source

pub fn add_proxy<'a, I>(&mut self, name: &str, params: I) -> &mut Self
where I: IntoIterator<Item = (&'a str, &'a str)>,

Adds a proxy to the material.

Source

pub fn to_string(&self) -> Result<String, Error>

Serializes the VMT back into a KeyValues string.

Source

pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Serializes the VMT and writes it to a file.

Source§

impl Vmt

Source

pub fn get_block<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, Error>

Deserializes a specific block into a Serde-compatible struct.

Source§

impl Vmt

Source

pub fn proxies(&self) -> Vec<Proxy>

Extracts and flattens all proxies into an ordered list.

Source§

impl Vmt

Source

pub fn apply_patch(&mut self, patch: &Vmt)

Applies patch instructions (insert/replace) to this VMT.

Trait Implementations§

Source§

impl Clone for Vmt

Source§

fn clone(&self) -> Vmt

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Vmt

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Vmt

Source§

fn eq(&self, other: &Vmt) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Vmt

Auto Trait Implementations§

§

impl Freeze for Vmt

§

impl RefUnwindSafe for Vmt

§

impl Send for Vmt

§

impl Sync for Vmt

§

impl Unpin for Vmt

§

impl UnsafeUnpin for Vmt

§

impl UnwindSafe for Vmt

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.