# DeviceUsbBinding

`import { DeviceUsbBinding } from "destack:device/binding";`

Usb binding family.

```ds title="DeviceUsbBinding"
export interface DeviceUsbBinding {
    listUsbDevices(): Result<UsbDevice[], HostError>;
    openUsbWatch(): Result<UsbWatchHandle, HostError>;
    closeUsbWatch(watch: UsbWatchHandle): Result<void, HostError>;
    readUsbWatch(watch: UsbWatchHandle, timeoutNs?: uint64 | undefined): Result<UsbWatchEvent, HostError>;
    openUsbDevice(id: &'a readonly string): Result<UsbDeviceHandle, HostError>;
    closeUsbDevice(device: UsbDeviceHandle): Result<void, HostError>;
    describeUsbDevice(device: UsbDeviceHandle): Result<UsbDevice, HostError>;
    listUsbConfigurations(device: UsbDeviceHandle): Result<UsbConfiguration[], HostError>;
    getUsbConfiguration(device: UsbDeviceHandle): Result<uint8, HostError>;
    setUsbConfiguration(device: UsbDeviceHandle, configuration: uint8): Result<void, HostError>;
    listUsbInterfaces(device: UsbDeviceHandle, configuration: uint8): Result<UsbInterface[], HostError>;
    claimUsbInterface(device: UsbDeviceHandle, interfaceNumber: uint8): Result<void, HostError>;
    releaseUsbInterface(device: UsbDeviceHandle, interfaceNumber: uint8): Result<void, HostError>;
    setUsbAlternateInterface(device: UsbDeviceHandle, interfaceNumber: uint8, alternateSetting: uint8): Result<void, HostError>;
    listUsbEndpoints(device: UsbDeviceHandle, interfaceNumber: uint8, alternateSetting: uint8): Result<UsbEndpoint[], HostError>;
    clearUsbHalt(device: UsbDeviceHandle, endpoint: UsbEndpointSelector): Result<void, HostError>;
    resetUsbDevice(device: UsbDeviceHandle): Result<void, HostError>;
    readUsbDescriptor(device: UsbDeviceHandle, descriptorType: uint8, descriptorIndex: uint8, languageId: uint16, buffer: &'a [uint8]): Result<uint64, HostError>;
    readUsbControl(device: UsbDeviceHandle, setup: UsbControlSetup, buffer: &'a [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    writeUsbControl(device: UsbDeviceHandle, setup: UsbControlSetup, bytes: &'a readonly [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    readUsbBulk(device: UsbDeviceHandle, endpoint: uint8, buffer: &'a [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    writeUsbBulk(device: UsbDeviceHandle, endpoint: uint8, bytes: &'a readonly [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    readUsbInterrupt(device: UsbDeviceHandle, endpoint: uint8, buffer: &'a [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    writeUsbInterrupt(device: UsbDeviceHandle, endpoint: uint8, bytes: &'a readonly [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    readUsbIsochronous(device: UsbDeviceHandle, endpoint: uint8, buffer: &'a [uint8], packetByteCounts: &'b readonly [uint32], packets: &'c [UsbIsochronousPacket], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    writeUsbIsochronous(device: UsbDeviceHandle, endpoint: uint8, bytes: &'a readonly [uint8], packetByteCounts: &'b readonly [uint32], packets: &'c [UsbIsochronousPacket], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>;
    cancelUsbTransfers(device: UsbDeviceHandle, endpoint?: UsbEndpointSelector | undefined): Result<void, HostError>;
}
```

[language/library/src/device/binding/usb.ds:246:553](https://github.com/destack-sh/destack/blob/main/language/library/src/device/binding/usb.ds#L246-L553)

## Members

### `listUsbDevices(): Result<UsbDevice[], HostError>`

List USB devices.

### `openUsbWatch(): Result<UsbWatchHandle, HostError>`

Open a USB topology watch.

### `closeUsbWatch(watch: UsbWatchHandle): Result<void, HostError>`

Close a USB topology watch.

### `readUsbWatch(watch: UsbWatchHandle, timeoutNs?: uint64 | undefined): Result<UsbWatchEvent, HostError>`

Read one USB topology event.

### `openUsbDevice(id: &'a readonly string): Result<UsbDeviceHandle, HostError>`

Open a USB device.

### `closeUsbDevice(device: UsbDeviceHandle): Result<void, HostError>`

Close a USB device.

### `describeUsbDevice(device: UsbDeviceHandle): Result<UsbDevice, HostError>`

Describe an open USB device.

### `listUsbConfigurations(device: UsbDeviceHandle): Result<UsbConfiguration[], HostError>`

List USB configurations.

### `getUsbConfiguration(device: UsbDeviceHandle): Result<uint8, HostError>`

Read the active USB configuration.

### `setUsbConfiguration(device: UsbDeviceHandle, configuration: uint8): Result<void, HostError>`

Select the active USB configuration.

### `listUsbInterfaces(device: UsbDeviceHandle, configuration: uint8): Result<UsbInterface[], HostError>`

List USB interfaces.

### `claimUsbInterface(device: UsbDeviceHandle, interfaceNumber: uint8): Result<void, HostError>`

Claim a USB interface.

### `releaseUsbInterface(device: UsbDeviceHandle, interfaceNumber: uint8): Result<void, HostError>`

Release a USB interface.

### `setUsbAlternateInterface(device: UsbDeviceHandle, interfaceNumber: uint8, alternateSetting: uint8): Result<void, HostError>`

Select one USB interface alternate setting.

### `listUsbEndpoints(device: UsbDeviceHandle, interfaceNumber: uint8, alternateSetting: uint8): Result<UsbEndpoint[], HostError>`

List USB endpoints.

### `clearUsbHalt(device: UsbDeviceHandle, endpoint: UsbEndpointSelector): Result<void, HostError>`

Clear one halted USB endpoint.

### `resetUsbDevice(device: UsbDeviceHandle): Result<void, HostError>`

Reset one USB device.

### `readUsbDescriptor(device: UsbDeviceHandle, descriptorType: uint8, descriptorIndex: uint8, languageId: uint16, buffer: &'a [uint8]): Result<uint64, HostError>`

Read one raw USB descriptor.

### `readUsbControl(device: UsbDeviceHandle, setup: UsbControlSetup, buffer: &'a [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Read bytes with a USB control transfer.

### `writeUsbControl(device: UsbDeviceHandle, setup: UsbControlSetup, bytes: &'a readonly [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Write bytes with a USB control transfer.

### `readUsbBulk(device: UsbDeviceHandle, endpoint: uint8, buffer: &'a [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Read bytes from a USB bulk endpoint.

### `writeUsbBulk(device: UsbDeviceHandle, endpoint: uint8, bytes: &'a readonly [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Write bytes to a USB bulk endpoint.

### `readUsbInterrupt(device: UsbDeviceHandle, endpoint: uint8, buffer: &'a [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Read bytes from a USB interrupt endpoint.

### `writeUsbInterrupt(device: UsbDeviceHandle, endpoint: uint8, bytes: &'a readonly [uint8], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Write bytes to a USB interrupt endpoint.

### `readUsbIsochronous(device: UsbDeviceHandle, endpoint: uint8, buffer: &'a [uint8], packetByteCounts: &'b readonly [uint32], packets: &'c [UsbIsochronousPacket], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Read USB isochronous packets.

### `writeUsbIsochronous(device: UsbDeviceHandle, endpoint: uint8, bytes: &'a readonly [uint8], packetByteCounts: &'b readonly [uint32], packets: &'c [UsbIsochronousPacket], timeoutNs?: uint64 | undefined): Result<UsbTransferResult, HostError>`

Write USB isochronous packets.

### `cancelUsbTransfers(device: UsbDeviceHandle, endpoint?: UsbEndpointSelector | undefined): Result<void, HostError>`

Cancel pending USB transfers.
