Registry / devops / asyncapi-rust-ws-template

asyncapi-rust-ws-template

JSON →
library0.3.2jsnpmunverified

AsyncAPI Rust WebSocket Template is an npm package used as a template for the AsyncAPI Generator to produce a Rust WebSocket client crate. As of version 0.3.2, it targets AsyncAPI v3 documents and generates client code using tokio-tungstenite or async-tungstenite frameworks. It processes spec components (info, servers, channels, messages) to produce a Rust project with Cargo.toml, lib.rs, client modules, and model definitions. Released on GitHub, it is a community-maintained tool for generating Rust WebSocket clients from AsyncAPI specs. Differentiators include direct integration with the AsyncAPI Generator ecosystem and support for multiple Rust async frameworks.

npm install asyncapi-rust-ws-template
INSTALL
IMPORT
SIG · ASYNCAPI-RUST-WS-T
A
asyncapi-rust-ws-template
devopsjavascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import generate from 'asyncapi-rust-ws-template'
const generate = require('asyncapi-rust-ws-template')
The package uses ESM exports; CommonJS require is not supported.
generate
import { generate } from 'asyncapi-rust-ws-template'
The generate function is the default export, but named import is also available.
TemplateParameters
import type { TemplateParameters } from 'asyncapi-rust-ws-template'
import { TemplateParameters } from 'asyncapi-rust-ws-template'
TemplateParameters is only exported as a TypeScript type, not a value. Use type import.

Shows two ways to use the template: CLI via asyncapi-generator, and programmatic usage with TypeScript.

// Install AsyncAPI Generator and this template // npm install -g @asyncapi/cli // npm install asyncapi-rust-ws-template // Generate a Rust WebSocket client from an AsyncAPI v3 YAML file // asyncapi generate fromTemplate asyncapi.yaml asyncapi-rust-ws-template -p exchange=my_exchange -o ./output // To use in code: import generate from 'asyncapi-rust-ws-template'; import { readFileSync } from 'fs'; const asyncapiDoc = JSON.parse(readFileSync('asyncapi.json', 'utf8')); const outputDir = './rust-client'; const parameters = { exchange: 'my_exchange', framework: 'tokio-tungstenite', validate: 'true' }; generate(asyncapiDoc, outputDir, parameters) .then(() => console.log('Client generated')) .catch(err => console.error(err));
Debug
Known issues
breakingRequires AsyncAPI v3 documents; v2 documents are not supported and may cause errors.
fix
Convert your AsyncAPI document to v3 format before using this template.
affects: >=0.0.0
gotchaThe template expects exactly one exchange name parameter. Without it, generation may produce incomplete code.
fix
Always provide the `exchange` parameter via -p exchange=EXCHANGE_NAME.
affects: >=0.0.0
deprecatedThe `validate` parameter must be set to 'true' as a string, not boolean. In earlier versions it was boolean, but now it's string-only.
fix
Use `-p validate=true` (string) instead of `-p validate` (boolean flag).
affects: >=0.2.0
gotchaOnly tokio-tungstenite and async-tungstenite frameworks are supported. Other frameworks will cause generation failure.
fix
Use only supported framework values: 'tokio-tungstenite' or 'async-tungstenite'.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'asyncapi-rust-ws-template'
Package not installed or not in NODE_PATH when using CLI generator.
fix
Run `npm install -g asyncapi-rust-ws-template` or install locally in the same directory.
Error: Invalid parameter value for 'framework'
Provided framework name not in the list of supported frameworks.
fix
Use 'tokio-tungstenite' or 'async-tungstenite' for the framework parameter.
Error: Template parameter 'exchange' is missing
Required exchange parameter not provided via -p flag.
fix
Add `-p exchange=YOUR_EXCHANGE_NAME` to the asyncapi generate command.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
asyncapi-rust-ws-template — npm install asyncapi-rust-ws-template · libregistry