import { type Operation } from "effection"; import type { PolicyArgs, PolicyHandlerResult, PolicyShape } from "../policy.js"; /** * A parsed Cargo.toml represented as a record of sections and values. * * @alpha */ export type CargoToml = Record; /** * A policy handler for Cargo.toml policies. * * @remarks * Receives the parsed TOML content and the standard policy arguments. * * @alpha */ export type CargoTomlHandler = (toml: CargoToml, args: PolicyArgs) => Operation | Promise; /** * Input arguments for defining a Cargo.toml policy. * * @alpha */ export interface DefineCargoPolicyArgs { /** * The name of the policy. */ name: string; /** * A description of the policy's purpose. */ description: string; /** * The handler function that receives the parsed Cargo.toml and policy arguments. */ handler: CargoTomlHandler; /** * Optional default configuration for the policy. */ defaultConfig?: C; } /** * Define a repo policy for Cargo.toml files. * * @remarks * This is a helper function that creates a policy pre-configured to match * Cargo.toml files. The handler receives the parsed TOML content. * * @example * ```typescript * const MyCargoPolicy = defineCargoPolicy({ * name: "MyCargoPolicy", * description: "Ensures Cargo.toml has required fields", * handler: async (toml, { file }) => { * const pkg = toml.package as Record | undefined; * if (!pkg?.name) { * return { error: "Missing package name", fixable: false }; * } * return true; * }, * }); * ``` * * @alpha */ export declare function defineCargoPolicy(args: DefineCargoPolicyArgs): PolicyShape; //# sourceMappingURL=defineCargoPolicy.d.ts.map