librashader/librashader-reflect/src/front/mod.rs

19 lines
616 B
Rust
Raw Normal View History

use crate::error::ShaderCompileError;
use librashader_preprocess::ShaderSource;
2024-02-07 22:26:17 -05:00
mod glslang;
2024-02-07 22:26:17 -05:00
pub use crate::front::glslang::GlslangCompilation;
/// Trait for types that can compile shader sources into a compilation unit.
pub trait ShaderCompilation: Sized {
/// Compile the input shader source file into a compilation unit.
fn compile(source: &ShaderSource) -> Result<Self, ShaderCompileError>;
}
impl<T: for<'a> TryFrom<&'a ShaderSource, Error = ShaderCompileError>> ShaderCompilation for T {
fn compile(source: &ShaderSource) -> Result<Self, ShaderCompileError> {
source.try_into()
}
}