Struct Input

Source
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

Source

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.

Source

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.

Source

pub fn input_directory(&self, dir_in: &str) -> PathBuf

Return the path to the input directory.

Source

pub fn output_directory(subdirectory: &str, dir_out: &str) -> PathBuf

Return the path to the output directory.

Source

pub fn input_path(&self, dir_in: &str) -> PathBuf

Return the path to the input file.

Source

pub fn output_path( &self, subdirectory: &str, extension: &str, dir_out: &str, ) -> PathBuf

Source

pub fn read_source(&self, dir_in: &str, print: bool) -> String

Return the contents of the input file as a string.

Source

pub fn read_bytes(&self, dir_in: &str, print: bool) -> Vec<u8>

Return the contents of the input file as a vector of bytes.

Source

pub fn bytes(&self, dir_in: &str) -> u64

Source

pub fn read_parameters(&self, dir_in: &str) -> Parameters

Return this input’s parameter file, parsed.

Source

pub fn write_output_file( &self, subdirectory: &str, extension: &str, data: impl AsRef<[u8]>, dir_out: &str, )

Write data to a file corresponding to this input file in subdirectory, with extension.

Trait Implementations§

Source§

impl Debug for Input

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnwindSafe for Input

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.