defineCargoPolicy
defineCargoPolicy<
C>(args):PolicyShape<C>
Defined in: policyDefiners/defineCargoPolicy.ts:99
Define a repo policy for Cargo.toml files.
Type Parameters
Section titled “Type Parameters”C = undefined
Parameters
Section titled “Parameters”Policy metadata, parsed-TOML handler, and optional defaults.
Returns
Section titled “Returns”PolicyShape<C>
A file policy that reads and parses matching Cargo.toml files.
Remarks
Section titled “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
Section titled “Example”const MyCargoPolicy = defineCargoPolicy({ name: "MyCargoPolicy", description: "Ensures Cargo.toml has required fields", handler: async (toml, { file }) => { const pkg = toml.package as Record<string, unknown> | undefined; if (!pkg?.name) { return { error: "Missing package name", fixable: false }; } return true; },});