Files
wsg/lib/src/utils/README.md
T

1.2 KiB

Utils Module — Configuration and Error Handling

Overview

The utils module defines two leaf concepts that other modules consume but have no internal dependencies on. As a leaf module, it does not import from any other library submodule.

File Responsibility
conf Shared constants for shader paths (STANDARD_SHADER_PATH) and embedded WGSL source code (STANDARD_SHADER). Centralized here so all submodules import from one place instead of duplicating literal strings. Enables PipelineCache to fall back to an embedded default shader when the file-based one is missing.
error WsgError enum — application-level error type mapping specific wgpu failure modes to user-friendly messages via thiserror. Every variant maps a GPU initialization or rendering failure to a recoverable or fatal outcome.

Interaction with Other Modules

  • pipeline::pipeline_cache: load_shader() reads STANDARD_SHADER_PATH from disk; falls back to STANDARD_SHADER if unreadable.
  • core::context: Returns WsgError variants from all fallible methods (new, configure, begin_frame).
  • core::renderer: Does not use errors directly — panics on invalid state rather than returning Result.