pub struct ShaderWatcher {
pub watch_paths: Vec<String>,
pub poll_interval_ms: u64,
pub sources: HashMap<String, ShaderSource>,
/* private fields */
}Expand description
Watches a collection of named WGSL shader sources for changes.
In a no-filesystem context (embedded, WASM, tests) changes are driven
explicitly by calling ShaderWatcher::update_source. On native
targets an optional polling loop can check file modification times
(see ShaderWatcher::poll_changes).
Fields§
§watch_paths: Vec<String>Filesystem paths added via Self::add_path; stored for future polling.
poll_interval_ms: u64Polling interval hint in milliseconds (informational only).
sources: HashMap<String, ShaderSource>All tracked sources keyed by label.
Implementations§
Source§impl ShaderWatcher
impl ShaderWatcher
Sourcepub fn add_path(&mut self, path: impl Into<String>)
pub fn add_path(&mut self, path: impl Into<String>)
Register a filesystem path to watch.
The label used for the source will be the path string itself.
The file is not loaded immediately; call Self::update_source with its
content or rely on a future polling implementation.
Sourcepub fn add_inline(&mut self, label: impl Into<String>, wgsl: impl Into<String>)
pub fn add_inline(&mut self, label: impl Into<String>, wgsl: impl Into<String>)
Register an inline WGSL source by label. If a source with the same
label already exists it is replaced (version resets to 1).
Sourcepub fn poll_changes(&mut self) -> Vec<ShaderChangeEvent>
pub fn poll_changes(&mut self) -> Vec<ShaderChangeEvent>
Check whether any tracked sources have changed since the last call to
poll_changes.
In the current implementation changes are detected purely by comparing
in-memory version numbers; actual filesystem polling is not yet wired up.
Returns the list of ShaderChangeEvents describing what changed.
Sourcepub fn update_source(
&mut self,
label: &str,
new_wgsl: impl Into<String>,
) -> bool
pub fn update_source( &mut self, label: &str, new_wgsl: impl Into<String>, ) -> bool
Force-update the WGSL source for an existing label, bumping its
version. Returns true on success, false if the label is unknown.
Sourcepub fn get_source(&self, label: &str) -> Option<&ShaderSource>
pub fn get_source(&self, label: &str) -> Option<&ShaderSource>
Look up a source by label.
Sourcepub fn source_version(&self, label: &str) -> Option<u64>
pub fn source_version(&self, label: &str) -> Option<u64>
Return the current version of a source, or None if the label is
not registered.