This release adds new method overloads to Device.Read
and Device.ReadTimeout
. The original signature required the caller to pass in the size of the buffer, allowing HidApi.Net to allocate the buffer and return the result.
The new signatures allow the caller to directly pass in a buffer of type Span<byte>
. This gives the caller some benefits:
- Allow to reuse an existing buffer, thus avoiding unnecessary buffer allocations.
- As
Span<T>
can represent different kinds of memory (managed, native, stack) the caller can decide which kind of memory should be used.
What's Changed
- Add Read overloads for passing in buffer by @TimonLukas in #102
- Fix internal methods using ReadOnlySpans as writable by @TimonLukas in #104
- Restore read method signatures by @badcel in #105
New Contributors
- @TimonLukas made their first contribution in #102
Full Changelog: 1.0.4...1.1.0