0.22.0 • Published 9 months ago

@kinobi-so/renderers-rust v0.22.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Kinobi ➤ Renderers ➤ Rust

npm npm-downloads

This package generates Rust clients from your Kinobi IDLs.

Installation

pnpm install @kinobi-so/renderers-rust

!NOTE This package is not included in the main kinobi package.

However, note that the renderers package re-exports the renderVisitor function of this package as renderRustVisitor.

Usage

Once you have a Kinobi IDL, you can use the renderVisitor of this package to generate Rust clients. You will need to provide the base directory where the generated files will be saved and an optional set of options to customize the output.

// node ./kinobi.mjs
import { renderVisitor } from '@kinobi-so/renderers-rust';

const pathToGeneratedFolder = path.join(__dirname, 'clients', 'rust', 'src', 'generated');
const options = {}; // See below.
kinobi.accept(renderVisitor(pathToGeneratedFolder, options));

Options

The renderVisitor accepts the following options.

NameTypeDefaultDescription
deleteFolderBeforeRenderingbooleantrueWhether the base directory should be cleaned before generating new files.
formatCodebooleanfalseWhether we should use cargo fmt to format the generated code. When set to true, the crateFolder option must be provided.
toolchainstring"+stable"The toolchain to use when formatting the generated code.
crateFolderstringnoneThe path to the root folder of the Rust crate. This option is required when formatCode is set to true.
linkOverridesRecord<'accounts' \| 'definedTypes' \| 'instructions' \| 'pdas' \| 'programs' \| 'resolvers', Record<string, string>>{}A object that overrides the import path of link nodes. For instance, { definedTypes: { counter: 'hooked' } } uses the hooked folder to import any link node referring to the counter type.
dependencyMapRecord<string, string>{}A mapping between import aliases and their actual crate name or path in Rust.
renderParentInstructionsbooleanfalseWhen using nested instructions, whether the parent instructions should also be rendered. When set to false (default), only the instruction leaves are being rendered.
0.21.8

9 months ago

0.21.7

9 months ago

0.22.0

9 months ago

0.21.0

11 months ago

0.20.11

12 months ago

0.20.12

12 months ago

0.20.10

1 year ago

0.20.9

1 year ago

0.20.8

1 year ago

0.21.6

10 months ago

0.20.7

1 year ago

0.21.5

10 months ago

0.21.4

10 months ago

0.21.3

10 months ago

0.21.2

11 months ago

0.21.1

11 months ago

0.20.6

1 year ago

0.20.5

1 year ago

0.20.4

1 year ago

0.20.3

1 year ago

0.20.2

1 year ago

0.20.1

1 year ago

0.20.0

1 year ago