{"id":46994,"library":"asyncapi-rust-ws-template","title":"AsyncAPI Rust WebSocket Client Template","description":"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.","status":"active","version":"0.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/kanekoshoyu/asyncapi-rust-websocket-template","tags":["javascript","asyncapi","generator","rust","websocket","tokio","template"],"install":[{"cmd":"npm install asyncapi-rust-ws-template","lang":"bash","label":"npm"},{"cmd":"yarn add asyncapi-rust-ws-template","lang":"bash","label":"yarn"},{"cmd":"pnpm add asyncapi-rust-ws-template","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package uses ESM exports; CommonJS require is not supported.","wrong":"const generate = require('asyncapi-rust-ws-template')","symbol":"default","correct":"import generate from 'asyncapi-rust-ws-template'"},{"note":"The generate function is the default export, but named import is also available.","wrong":"","symbol":"generate","correct":"import { generate } from 'asyncapi-rust-ws-template'"},{"note":"TemplateParameters is only exported as a TypeScript type, not a value. Use type import.","wrong":"import { TemplateParameters } from 'asyncapi-rust-ws-template'","symbol":"TemplateParameters","correct":"import type { TemplateParameters } from 'asyncapi-rust-ws-template'"}],"quickstart":{"code":"// Install AsyncAPI Generator and this template\n// npm install -g @asyncapi/cli\n// npm install asyncapi-rust-ws-template\n\n// Generate a Rust WebSocket client from an AsyncAPI v3 YAML file\n// asyncapi generate fromTemplate asyncapi.yaml asyncapi-rust-ws-template -p exchange=my_exchange -o ./output\n\n// To use in code:\nimport generate from 'asyncapi-rust-ws-template';\nimport { readFileSync } from 'fs';\n\nconst asyncapiDoc = JSON.parse(readFileSync('asyncapi.json', 'utf8'));\nconst outputDir = './rust-client';\nconst parameters = { exchange: 'my_exchange', framework: 'tokio-tungstenite', validate: 'true' };\ngenerate(asyncapiDoc, outputDir, parameters)\n  .then(() => console.log('Client generated'))\n  .catch(err => console.error(err));","lang":"typescript","description":"Shows two ways to use the template: CLI via asyncapi-generator, and programmatic usage with TypeScript."},"warnings":[{"fix":"Convert your AsyncAPI document to v3 format before using this template.","message":"Requires AsyncAPI v3 documents; v2 documents are not supported and may cause errors.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Always provide the `exchange` parameter via -p exchange=EXCHANGE_NAME.","message":"The template expects exactly one exchange name parameter. Without it, generation may produce incomplete code.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `-p validate=true` (string) instead of `-p validate` (boolean flag).","message":"The `validate` parameter must be set to 'true' as a string, not boolean. In earlier versions it was boolean, but now it's string-only.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Use only supported framework values: 'tokio-tungstenite' or 'async-tungstenite'.","message":"Only tokio-tungstenite and async-tungstenite frameworks are supported. Other frameworks will cause generation failure.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.3.2':32 'async':48,104 'async-tungstenit':47 'asyncapi':1,6,20,35,88,96,107 'cargo.toml':65 'channel':57 'client':4,27,40,67,86 'code':41 'communiti':79 'community-maintain':78 'compon':54 'crate':28 'definit':71 'differenti':90 'direct':92 'document':37 'ecosystem':98 'framework':50,105 'generat':21,39,83,97,108 'github':74 'includ':91 'info':55 'integr':93 'javascript':106 'lib.rs':66 'maintain':80 'messag':58 'model':70 'modul':68 'multipl':102 'npm':12 'packag':13 'process':52 'produc':23,60 'project':63 'releas':72 'rust':2,7,25,62,84,103,109 'server':56 'spec':53,89 'support':100 'target':34 'templat':5,9,17,112 'tokio':44,111 'tokio-tungstenit':43 'tool':81 'tungstenit':45,49 'use':14,42 'v3':36 'version':31 'websocket':3,8,26,85,110","created_at":"2026-06-07T16:49:12.488663+00:00","updated_at":"2026-06-07T16:49:12.488663+00:00","problems":[{"fix":"Run `npm install -g asyncapi-rust-ws-template` or install locally in the same directory.","cause":"Package not installed or not in NODE_PATH when using CLI generator.","error":"Error: Cannot find module 'asyncapi-rust-ws-template'"},{"fix":"Use 'tokio-tungstenite' or 'async-tungstenite' for the framework parameter.","cause":"Provided framework name not in the list of supported frameworks.","error":"Error: Invalid parameter value for 'framework'"},{"fix":"Add `-p exchange=YOUR_EXCHANGE_NAME` to the asyncapi generate command.","cause":"Required exchange parameter not provided via -p flag.","error":"Error: Template parameter 'exchange' is missing"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/kanekoshoyu/asyncapi-rust-websocket-template#readme","github":"https://github.com/kanekoshoyu/asyncapi-rust-websocket-template","docs":null,"changelog":null,"pypi":null,"npm":"asyncapi-rust-ws-template","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}