a1ien / rusb

A safe Rust wrapper for libusb.
Other
401 stars 83 forks source link

fix: Add missing fields to libusb_bos_descriptor and libusb_bos_dev_capability_descriptor #161

Closed alufers closed 5 months ago

alufers commented 1 year ago

This fix adds missing fields to these two structs so that they can be used from rust without the size mismatching from the C version.

See:

https://libusb.sourceforge.io/api-1.0/structlibusb__bos__descriptor.html https://libusb.sourceforge.io/api-1.0/structlibusb__bos__dev__capability__descriptor.html

alufers commented 1 year ago

Hello, any progress on this?

a1ien commented 1 year ago

This looks like breaking changes.

alufers commented 1 year ago

No, the fields are simply missing in the Rust version, causing memory corruption when they are not present.

a1ien commented 1 year ago

The statement about memory corruption is not true. In this example https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cfe918958abb877dbf05dc9a3d737c33 You can see that size and layout for structure is the same. The only downside of missing this filed is less ergonomic usage.

Yes, this filed missing in current rust version. But I can't accept this PR right now because this breaking change for users. I will merge this when I make a new release(0.7.0). Probably when 1.27 libusb released.

alufers commented 1 year ago

Okay, sorry for the false statement. Was remembering this from memory, probably confused something. No rush, I have worked around this, as you say - less ergonomically.

a1ien commented 5 months ago

Thank you. Merged.