RustQ.Generated (rustq v0.11.1)

Copy Markdown View Source

File sync helpers for RustQ-generated sources.

Most projects should use rustq.exs with mix rustq.gen. Use this module directly when a project already has its own Mix task and only needs RustQ's write/check behavior.

RustQ.Generated.sync!(:helpers,
  path: "native/my_nif/src/generated_helpers.rs",
  build: fn -> render_helpers() end
)

Pass check: true to compare without writing, which is useful in CI.

Summary

Functions

Raises StaleError when a generated file differs from expected content.

Loads and normalizes generated targets from a RustQ manifest.

Writes or checks one named generated target.

Writes or checks all selected generated targets.

Writes normalized generated content, creating parent directories.

Types

target()

@type target() :: {atom() | String.t(), keyword()}

Functions

check!(path, expected, opts \\ [])

@spec check!(Path.t(), iodata(), keyword()) :: :ok

Raises StaleError when a generated file differs from expected content.

load_manifest!(path \\ "rustq.exs")

@spec load_manifest!(Path.t()) :: [target()]

Loads and normalizes generated targets from a RustQ manifest.

sync!(name, target, opts \\ [])

@spec sync!(atom() | String.t(), keyword(), keyword()) :: :ok

Writes or checks one named generated target.

sync_all!(targets, opts \\ [])

@spec sync_all!(
  [target()],
  keyword()
) :: :ok

Writes or checks all selected generated targets.

write!(path, contents)

@spec write!(Path.t(), iodata()) :: :ok

Writes normalized generated content, creating parent directories.