pub struct ShaderDefines { /* private fields */ }Expand description
A collection of shader macro definitions.
Internally uses an ordered Vec<(Symbol, Symbol)> to store definitions,
ensuring that identical macro sets produce identical hash values.
§Performance
- Insertion/lookup: O(log n) due to binary search
- Hash computation: O(n) but cached
- Comparison: O(1) when using cached hashes
Implementations§
Source§impl ShaderDefines
impl ShaderDefines
Sourcepub fn new() -> ShaderDefines
pub fn new() -> ShaderDefines
Create empty shader defines collection
Sourcepub fn with_capacity(capacity: usize) -> ShaderDefines
pub fn with_capacity(capacity: usize) -> ShaderDefines
Create shader defines collection with pre-allocated capacity
Sourcepub fn set(&mut self, key: &str, value: &str)
pub fn set(&mut self, key: &str, value: &str)
Set shader define (maintains sorted order)
If key exists, updates its value; otherwise inserts new entry.
Sourcepub fn set_symbol(&mut self, key: Spur, value: Spur)
pub fn set_symbol(&mut self, key: Spur, value: Spur)
Set shader define using Symbol (internal method, more efficient)
Sourcepub fn remove_symbol(&mut self, key: Spur) -> bool
pub fn remove_symbol(&mut self, key: Spur) -> bool
Remove shader define using Symbol
Sourcepub fn contains_symbol(&self, key: Spur) -> bool
pub fn contains_symbol(&self, key: Spur) -> bool
Check if contains a shader define using Symbol
Sourcepub fn get_symbol(&self, key: Spur) -> Option<Cow<'static, str>>
pub fn get_symbol(&self, key: Spur) -> Option<Cow<'static, str>>
Get shader define value using Symbol
Sourcepub fn iter(&self) -> impl Iterator<Item = &(Spur, Spur)>
pub fn iter(&self) -> impl Iterator<Item = &(Spur, Spur)>
Iterate all shader defines (as Symbols)
Sourcepub fn iter_strings(&self) -> impl Iterator<Item = (String, String)>
pub fn iter_strings(&self) -> impl Iterator<Item = (String, String)>
Iterate all shader defines (as strings)
Sourcepub fn merge(&mut self, other: &ShaderDefines)
pub fn merge(&mut self, other: &ShaderDefines)
Merge shader defines from another ShaderDefines
If there are conflicts, values from other will override values in self.
Sourcepub fn merged_with(&self, other: &ShaderDefines) -> ShaderDefines
pub fn merged_with(&self, other: &ShaderDefines) -> ShaderDefines
Create a new merged ShaderDefines
Sourcepub fn compute_hash(&self) -> u64
pub fn compute_hash(&self) -> u64
Compute content hash (for caching)
Trait Implementations§
Source§impl Clone for ShaderDefines
impl Clone for ShaderDefines
Source§fn clone(&self) -> ShaderDefines
fn clone(&self) -> ShaderDefines
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShaderDefines
impl Debug for ShaderDefines
Source§impl Default for ShaderDefines
impl Default for ShaderDefines
Source§fn default() -> ShaderDefines
fn default() -> ShaderDefines
Source§impl From<&[(&str, &str)]> for ShaderDefines
Create ShaderDefines from list of macro definitions
impl From<&[(&str, &str)]> for ShaderDefines
Create ShaderDefines from list of macro definitions
Source§impl Hash for ShaderDefines
impl Hash for ShaderDefines
Source§impl PartialEq for ShaderDefines
impl PartialEq for ShaderDefines
impl Eq for ShaderDefines
Auto Trait Implementations§
impl Freeze for ShaderDefines
impl RefUnwindSafe for ShaderDefines
impl Send for ShaderDefines
impl Sync for ShaderDefines
impl Unpin for ShaderDefines
impl UnsafeUnpin for ShaderDefines
impl UnwindSafe for ShaderDefines
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().