Function write_byte_arrays

Source
pub fn write_byte_arrays(
    struct_output_path: &Path,
    struct_name: &str,
    byte_arrays: Vec<(&str, Bytes)>,
) -> Result<()>
Expand description

Writes binary files to OUT_DIR/embed/ and generates a Rust struct in src/.

  • Binary files are written to OUT_DIR/embed/.
  • The generated .rs file is placed at src/<struct_name>.rs.

If the embed-bytes feature is enabled, the struct contains constants referencing the binary files using include_bytes!. Otherwise, they are empty arrays with a deprecation warning.

§Arguments

  • struct_output_path - The path to src/<struct_name>.rs.
  • struct_name - The name of the generated struct.
  • byte_arrays - A vector of tuples (field_name, content), where field_name is the associated constant and content is the binary.

§Errors

Returns an io::Error if any file operation fails.