{"id":15645804,"url":"https://github.com/littledivy/webusb","last_synced_at":"2025-04-05T15:07:23.750Z","repository":{"id":43791878,"uuid":"402827134","full_name":"littledivy/webusb","owner":"littledivy","description":"WebUSB API implementation in Rust (and Deno)","archived":false,"fork":false,"pushed_at":"2024-10-19T06:17:07.000Z","size":83,"stargazers_count":61,"open_issues_count":3,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T14:09:51.645Z","etag":null,"topics":["deno","ffi","rust","usb","webusb"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/webusb","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/littledivy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"littledivy"}},"created_at":"2021-09-03T16:07:19.000Z","updated_at":"2025-03-27T02:51:42.000Z","dependencies_parsed_at":"2024-12-15T21:06:23.962Z","dependency_job_id":"369005c6-12fe-4f8f-a340-ef40576a4e06","html_url":"https://github.com/littledivy/webusb","commit_stats":{"total_commits":68,"total_committers":1,"mean_commits":68.0,"dds":0.0,"last_synced_commit":"be49bdac21f7479574f3b680f9c4ac75c16b6458"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fwebusb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fwebusb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fwebusb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fwebusb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/littledivy","download_url":"https://codeload.github.com/littledivy/webusb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353745,"owners_count":20925329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","ffi","rust","usb","webusb"],"created_at":"2024-10-03T12:09:54.004Z","updated_at":"2025-04-05T15:07:23.721Z","avatar_url":"https://github.com/littledivy.png","language":"Rust","funding_links":["https://github.com/sponsors/littledivy"],"categories":[],"sub_categories":[],"readme":"# webusb\n\nImplementation of the [WebUSB specification](https://wicg.github.io/webusb/) in\nRust.\n\n[![Documentation](https://docs.rs/webusb/badge.svg)](https://docs.rs/webusb)\n[![Package](https://img.shields.io/crates/v/webusb.svg)](https://crates.io/crates/webusb)\n[![Coverage Status](https://coveralls.io/repos/github/littledivy/webusb/badge.svg)](https://coveralls.io/github/littledivy/webusb)\n\n```toml\n[dependencies]\nwebusb = \"0.5.0\"\n```\n\n### Usage with Deno\n\n```typescript\nimport \"https://deno.land/x/webusb/mod.ts\";\n\nconst devices = await navigator.usb.getDevices();\n// Arduino Leonardo\nlet device = devices.find((p) =\u003e p.productId == 0x8036);\n\nawait device.open();\nconsole.log(\"Device opened.\");\n\nif (device.configuration === null) {\n  device.selectConfiguration(1);\n}\n\nconsole.log(`${device.productName} - ${device.serialNumber}`);\n\nawait device.claimInterface(2);\nawait device.selectAlternateInterface(2, 0);\nawait device.controlTransferOut({\n  \"requestType\": \"class\",\n  \"recipient\": \"interface\",\n  \"request\": 0x22,\n  \"value\": 0x01,\n  \"index\": 2,\n});\n\nwhile (true) {\n  const action = prompt(\"\u003e\u003e\");\n  if (action.toLowerCase() == \"exit\") break;\n  const data = new TextEncoder().encode(action);\n  await device.transferOut(4, data);\n  console.info(\"Transfer.\");\n}\n\nawait device.controlTransferOut({\n  \"requestType\": \"class\",\n  \"recipient\": \"interface\",\n  \"request\": 0x22,\n  \"value\": 0x00,\n  \"index\": 2,\n});\n\nawait device.close();\nconsole.log(\"Bye.\");\n```\n\n### Testing\n\nHardware tests are run before merging a PR and then on `main`. The test runner\nis a self-hosted Linux x86_64 machine, it is connected to an Arduino Leonardo\n(ATmega32u4) via micro USB connection.\n\nTests are reviewed and triggered by maintainers on PRs to prevent malicious\nexecution. Load\n[this sketch](https://github.com/webusb/arduino/blob/gh-pages/demos/console/sketch/sketch.ino)\ninto yours to run the tests locally.\n\nWhen writing tests you might encounter frequent Io / NoDevice errors, this can\nbe due to loose wired connection. Mark these tests as\n`#[flaky_test::flaky_test]`.\n\n### License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittledivy%2Fwebusb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittledivy%2Fwebusb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittledivy%2Fwebusb/lists"}