Skip to content

Expose out-of-memory errors #186

@kevinmehall

Description

@kevinmehall

We could consider adding a TransferError variant for when the transfer fails due to out-of-memory. This is a breaking change because it's not #[non_exhaustive]. However, TransferError is supposed to be cross-platform, but the way memory limits work differs between operating systems:

  • Linux has a global memory limit /sys/module/usbcore/parameters/usbfs_memory_mb for allocated zero-copy buffers as well as in-flight transfers backed by regular memory. When exceeded when submitting a transfer, we currently return TransferError::Unknown(12) (ENOMEM).
  • Windows: has a per-transfer limit that is normally 2MB. When exceeded, it fails with TransferError::Unknown(1) (ERROR_INVALID_FUNCTION) and the underlying NTSTATUS is STATUS_INVALID_DEVICE_REQUEST. Not sure if other invalid parameters can fail with the same error.
  • macOS: ???

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeIs or requires a semver-breaking API change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions