You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't find a way to hold a DeviceHandle in a struct and pass it around. It has a lifetime that must be longer than the Context object that created it. However, even when Boxing the Context and the DeviceHandle together, it's impossible to store a handle.
Did anyone get this to work? I need to store the handle because of how I have a transport-agnostic library built. It also uses the hid crate where the Handle type does not have a lifetime defined, but just documents that it cannot outlive the HidManager type. So I can just manually drop the Handle before dropping the manager.
@dcuddeback I saw a comment where you assume all users will create the Context in main and then just keep it around. Well, I'm not an end user, but a library implementer. The library connects to devices that support with WebUSB, HID and an HTTP bridge daemon. So the Context is created inside the library code and it's impossible to create the context and have it outlive the interface client object that the library returns.
The text was updated successfully, but these errors were encountered:
I'm having the same issue, I need to return a struct from a function with a DeviceHandle inside. I'm fine with making the struct also hold another Context, specifically created for the struct instance, but I can't find a way to tell the borrow checker that what I'm trying to do is fine.
Did you happen to find a way without resorting to unsafe?
I can't find a way to hold a
DeviceHandle
in a struct and pass it around. It has a lifetime that must be longer than theContext
object that created it. However, even when Boxing the Context and the DeviceHandle together, it's impossible to store a handle.Did anyone get this to work? I need to store the handle because of how I have a transport-agnostic library built. It also uses the
hid
crate where theHandle
type does not have a lifetime defined, but just documents that it cannot outlive theHidManager
type. So I can just manually drop the Handle before dropping the manager.@dcuddeback I saw a comment where you assume all users will create the
Context
in main and then just keep it around. Well, I'm not an end user, but a library implementer. The library connects to devices that support with WebUSB, HID and an HTTP bridge daemon. So theContext
is created inside the library code and it's impossible to create the context and have it outlive the interface client object that the library returns.The text was updated successfully, but these errors were encountered: