pub struct Input {
pub subdirectory: PathBuf,
pub file_name: PathBuf,
pub keep_input_extension: bool,
}
Expand description
Information about a shader input file.
Fields§
§subdirectory: PathBuf
The subdirectory of tests/in
to which this input belongs, if any.
If the subdirectory is omitted, we assume that the output goes to “wgsl”.
file_name: PathBuf
The input filename name, without a directory.
keep_input_extension: bool
True if output filenames should add the output extension on top of
file_name
’s existing extension, rather than replacing it.
This is used by convert_snapshots_glsl
, which wants to take input files
like 210-bevy-2d-shader.frag
and just add .wgsl
to it, producing
210-bevy-2d-shader.frag.wgsl
.
Implementations§
Source§impl Input
impl Input
Sourcepub fn new(subdirectory: &str, name: &str, extension: &str) -> Input
pub fn new(subdirectory: &str, name: &str, extension: &str) -> Input
Read an input file and its corresponding parameters file.
Given input
, the relative path of a shader input file, return
a Source
value containing its path, code, and parameters.
The input
path is interpreted relative to the BASE_DIR_IN
subdirectory of the directory given by the CARGO_MANIFEST_DIR
environment variable.
Sourcepub fn files_in_dir<'a>(
subdirectory: &'a str,
file_extensions: &'a [&'a str],
dir_in: &str,
) -> impl Iterator<Item = Input> + 'a
pub fn files_in_dir<'a>( subdirectory: &'a str, file_extensions: &'a [&'a str], dir_in: &str, ) -> impl Iterator<Item = Input> + 'a
Return an iterator that produces an Input
for each entry in subdirectory
.
Sourcepub fn input_directory(&self, dir_in: &str) -> PathBuf
pub fn input_directory(&self, dir_in: &str) -> PathBuf
Return the path to the input directory.
Sourcepub fn output_directory(subdirectory: &str, dir_out: &str) -> PathBuf
pub fn output_directory(subdirectory: &str, dir_out: &str) -> PathBuf
Return the path to the output directory.
Sourcepub fn input_path(&self, dir_in: &str) -> PathBuf
pub fn input_path(&self, dir_in: &str) -> PathBuf
Return the path to the input file.
pub fn output_path( &self, subdirectory: &str, extension: &str, dir_out: &str, ) -> PathBuf
Sourcepub fn read_source(&self, dir_in: &str, print: bool) -> String
pub fn read_source(&self, dir_in: &str, print: bool) -> String
Return the contents of the input file as a string.
Sourcepub fn read_bytes(&self, dir_in: &str, print: bool) -> Vec<u8> ⓘ
pub fn read_bytes(&self, dir_in: &str, print: bool) -> Vec<u8> ⓘ
Return the contents of the input file as a vector of bytes.
pub fn bytes(&self, dir_in: &str) -> u64
Sourcepub fn read_parameters(&self, dir_in: &str) -> Parameters
pub fn read_parameters(&self, dir_in: &str) -> Parameters
Return this input’s parameter file, parsed.