a1ien / rusb

A safe Rust wrapper for libusb.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use Result<..> as return type of `open_device_with_vid_pid`

J-ZhengLi opened this issue · comments

Currently this function returns an option which is impossible to know why it might fails to get a device handle.

I had to spent a few minutes checking everything to make sure they were correct, until I finally decided to loop thought the device list and open the desired one, and it turns out it was "Access denied"...

So, I'm guessing returning a result could be more helpful in this case.

It's not possible to return Result. Since this function use libusb_open_device_with_vid_pid from libusb and this function only return NULL ptr if error. Also it not recommended to use this function in real code. Only for fast test