Skip to main content

generate_from_abi

Function generate_from_abi 

Source
pub fn generate_from_abi(
    abi_path: impl AsRef<Path>,
    output_dir: impl AsRef<Path>,
) -> AptosResult<()>
Expand description

Generates Rust code from a single ABI file.

§Arguments

  • abi_path - Path to the ABI JSON file
  • output_dir - Directory where generated code will be written

§Errors

Returns an error if:

  • The ABI file cannot be read
  • The ABI JSON cannot be parsed
  • Code generation fails
  • The output directory cannot be created
  • The output file cannot be written

§Example

build_helper::generate_from_abi("abi/coin.json", "src/generated/")?;