Skip to main content

expand_str_to_file

Function expand_str_to_file 

Source
pub fn expand_str_to_file<P: AsRef<Path>>(
    spec: &str,
    dest: P,
) -> Result<PathBuf, CodegenError>
Expand description

Parse, validate, emit, pretty-print, and write the Rust code for a DSL string to dest. Parent directories are created if needed, and writes are performed atomically.

This helper creates parent directories if needed, writes atomically to dest, and returns the resolved path. It is ideal for use in build.rs, where you can later include!() the file.

§Parameters

  • spec: The graph DSL as a UTF-8 string. It must contain exactly one graph definition.
  • dest: Destination filesystem path for the generated Rust source file.

§Returns

  • Ok(PathBuf): The absolute path that was written.
  • Err(CodegenError): If parsing, validation, emission, pretty-printing, or I/O fails.

§Errors

Returns: