xidlc Usage Guide
Using xidlc
Section titled “Using xidlc”xidlc is the standard entry point for XIDL. It reads one or more .idl files and generates artifacts for the selected targets.
Establish the Correct Mental Model
Section titled “Establish the Correct Mental Model”The way xidlc works is straightforward:
- Input one or more IDL files.
- Select a target generator.
- Specify the output directory.
- Obtain the files corresponding to that target.
Minimal command:
xidlc gen --out-dir out rust path/to/file.idlShort version:
xidlc gen -o out rust path/to/file.idlCommon Parameters
Section titled “Common Parameters”--out-dir,-o: Specify the output directory.<lang>: Select the target generator subcommand underxidlc gen.--client: Generate additional client-related artifacts for targets that support this parameter.--server: Generate server-related artifacts for targets that support this parameter.--dry-run: Execute the parsing and generation process without writing files to disk.
Typical Workflows
Section titled “Typical Workflows”Generate Rust Types
Section titled “Generate Rust Types”xidlc gen -o src/generated rust api.idlGenerate Axum HTTP Bindings
Section titled “Generate Axum HTTP Bindings”xidlc gen -o src/generated rust-axum api.idlGenerate JSON-RPC Bindings
Section titled “Generate JSON-RPC Bindings”xidlc gen -o src/generated rust-jsonrpc api.idlGenerate OpenAPI
Section titled “Generate OpenAPI”xidlc gen -o generated openapi api.idlGenerate OpenRPC
Section titled “Generate OpenRPC”xidlc gen -o generated openrpc api.idlFormatting
Section titled “Formatting”The CLI also provides a formatting subcommand:
xidlc fmt path/to/file.idlIn-place formatting:
xidlc fmt --inplace path/to/file.idl