Skip to main content

generate_from_abis

Function generate_from_abis 

Source
pub fn generate_from_abis(
    abi_paths: &[impl AsRef<Path>],
    output_dir: impl AsRef<Path>,
) -> AptosResult<()>
Expand description

Generates Rust code from multiple ABI files.

Also generates a mod.rs file that re-exports all generated modules.

§Arguments

  • abi_paths - Paths to ABI JSON files
  • output_dir - Directory where generated code will be written

§Errors

Returns an error if:

  • Any ABI file cannot be read
  • Any ABI JSON cannot be parsed
  • Code generation fails for any module
  • The output directory cannot be created
  • Any output file cannot be written
  • The mod.rs file cannot be written

§Example

build_helper::generate_from_abis(&[
    "abi/coin.json",
    "abi/token.json",
], "src/generated/")?;