Implementation of the WebUSB specification in Rust.

Overview

webusb

Implementation of the WebUSB specification in Rust.

Documentation Package Coverage Status

[dependencies]
webusb = "0.3.0"

ko-fi

Async

The methods are marked as async for compability between the native and wasm target.

Testing

Hardware tests are run before merging a PR and then on main. The test runner is a self-hosted Linux x86_64 machine, it is connected to an Arduino Leonardo (ATmega32u4) via micro USB connection.

Tests are reviewed and triggered by maintainers on PRs to prevent malicious execution. Load this sketch into yours to run the tests locally.

When writing tests you might encounter frequent Io / NoDevice errors, this can be due to loose wired connection. Mark these tests as #[flaky_test::flaky_test].

License

MIT License

You might also like...
A Conway's Game of Life implementation in Rust & WASM
A Conway's Game of Life implementation in Rust & WASM

Rust Wasm Game of Life This repo contains an example implementation of Conway's Game of Life in Rust and WebAssembly. How to use You should have wasm-

KERI implementation in RUST, current development lead by DIF

KERIOX Introduction Features Introduction KERIOX is an open source Rust implementation of the Key Event Receipt Infrastructure (KERI) , a system desig

A rust implementation of the reverse-engineered Glorious mouse protocol

gloryctl This project is an implementation of the vendor-specific HID protocol in use by Glorious mice used to configure parameters such as DPI profil

Rust implementation of the Edge IoT framework

A Rust-based implementation of Edge-rs for the Raspberry Pi Pico Getting started For more details see the following article on getting started for get

The rust implementation of IPLD schemas and some associated functionalities.

Linked Data IPLD schemas and what to do with them. Beacon Directory of user content and metadata. Since this object should not change it can be used a

Rust implementation of Project Fluent

Fluent fluent-rs is a collection of Rust crates implementing Project Fluent. The crates perform the following functions: fluent Umbrella crate combini

DPDK's rte_ring implementation in Rust

rte_ring Ring library from DPDK ported to Rust. Based on DPDK 21.11.0. Features FIFO Maximum size is fixed, the pointers are stored in a table Lockles

A rust bencode encoding/decoding implementation backed by serde.

Bende A rust bencode encoding/decoding implementation backed by serde. About This is one of a few bencode implementations available for rust. Though t

Svix - A pure Rust and fully tested KSUID implementation

Svix - Webhooks as a service Svix-KSUID (Rust) A pure Rust and fully tested KSUID implementation This library is fully compatible with Segment's KSUID

Comments
  • Device class / typings are not exported

    Device class / typings are not exported

    It's impossible to declare TypeScript typings for a function that takes in a USB device as an argument, since it is not exported:

    import usb from "https://deno.land/x/[email protected]/mod.ts"
    
    const devices = await usb.getDevices()
    
    initDevice(devices[0])
    
    async function initDevice(device: /* what goes here? */) {
        await device.open()
        console.log(`${device.productName} - ${device.serialNumber}`);
    }
    

    Likewise, it's impossible to tell if an object is a USB device via an instanceof check, since the class isn't exported either.

    Could you consider exporting the types/classes?

    opened by MindfulMinun 2
  • Documentation: Context (and example?)

    Documentation: Context (and example?)

    To a newcomer looking at Rust support for WebUSB, the README is lacking information on where in the stack this sits -- could be for use for on the device itself (in embedded Rust), or could run in the browser (eg. through wasm-bindgen).

    From the dependencies, I get the impression that it's to be used natively on the host, and peeking at the projects you're involved in it might be the part of WebUSB that runs inside the browser, but that's a guess. If it is right, text like this could be helpful:

    This crate implements the browser part of the WebUSB specification. That is, it accesses the host system's USB devices through libusb, and provides the Navigator .usb object that is typically used through JavaScript.

    An example of how this is used can be found [in the deno source code](...).

    For different places in the stack where Rust and WebUSB can be used together, see [usbd-webusb](https://github.com/redpfire/usbd-webusb) (which would go into the device firmware itself), or [web-sys's Usb struct](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Usb.html) (which compiled to WebAssembly and run inside the browser). The present crate provides the code inbetween.

    (Note that I haven't used or tested usbd-webusb or this particular module of web-sys. These serve not so much as recommendations but more to frame how this crate is used.)

    documentation 
    opened by chrysn 1
Releases(0.5.0)
Owner
Divy Srivastava
17. Contributing to @denoland. Rust, Go and Typescript. Core team @useverto @nestdotland
Divy Srivastava
Rust implementation of the legacy Master Server Query Protocol

msq-rs Rust library implementation of the legacy Master Server Query Protocol. Documentation crates.io Repository Release Notes Usage Add this to your

mtcw 6 Nov 20, 2022
🦀 Rust-based implementation of a Snowflake Generator which communicates using gRPC

Clawflake Clawflake is a Rust application which implements Twitter Snowflakes and communicates using gRPC. Snowflake ID numbers are 63 bits integers s

n1c00o 5 Oct 31, 2022
Re-implementation of Panda Doodle in Rust targetting WASM, a mobile game originally written in C++

Description This is the source code of my game Panda Doodle, which can be played at https://pandadoodle.lucamoller.com/ (it's best playable on touch s

null 79 Dec 5, 2022
2D Predictive-Corrective Smoothed Particle Hydrodynamics (SPH) implementation in Rust with WASM + WebGL

pcisph-wasm 2D Predictive-Corrective Smoothed Particle Hydrodynamics (SPH) implementation in Rust with WASM + WebGL Reimplementation of my previous Ru

Lucas V. Schuermann 46 Dec 17, 2022
A Rust implementation of fractional indexing.

fractional_index This crate implements fractional indexing, a term coined by Figma in their blog post Realtime Editing of Ordered Sequences. Specifica

null 18 Dec 21, 2022
Pure rust implementation of jq

XQ JQ reimplemented purely in Rust. Caution This program is under development. You probably want to use the original implementation of jq, or pure Go

null 181 Jan 4, 2023
A pure Rust PLONK implementation using arkworks as a backend.

PLONK This is a pure Rust implementation of the PLONK zk proving system Usage use ark_plonk::prelude::*; use ark_ec::bls12::Bls12; use rand_core::OsRn

rust-zkp 201 Dec 31, 2022
A Bancho implementation made in Rust for the *cursed* stack.

cu.rs A Bancho implementation made in Rust for the cursed stack. THIS PROJECT IS REALLY UNFINISHED AND IN ITS EARLY STAGES A drag and drop replacement

RealistikOsu! 5 Feb 1, 2022
Golang like WaitGroup implementation for sync/async Rust.

wg Golang like WaitGroup implementation for sync/async Rust.

Al Liu 8 Dec 6, 2022
Hexdump implementation in Rust

Minimalistic hexdump implementation in Rust

null 1 Oct 25, 2021