TheButlah / ovr_overlay

Rust OpenVR bindings using an up-to-date OpenVR and autocxx
https://docs.rs/ovr_overlay
Other
7 stars 8 forks source link

Implement TrackedDeviceProperty for &CStr #18

Closed kitlith closed 1 year ago

kitlith commented 1 year ago

This was requested in #8, but I only figured out the lifetimes at the last minute. This is a bit ugly since it requires sprinkling lifetimes everywhere, but I didn't see another way to do it.

Ideally I'd have another way to express the inverse of Type: 'lifetime (which, naively, reading as Type outlives lifetime, would be lifetime outlives Type and thus 'lifetime: Type but that doesn't work) but oh well i guess.

TheButlah commented 1 year ago

I tried it out and experimented with removing the lifetime via HRTB, but was unsuccessful. Its unfortunate that this requires that, yeah :(

I haven't looked at your followup non-MVP version, but I would expect this can be fixed it there by having two traits - one for describing native openvr storage types, and one trait for generically getting those into rust types.

For now, I'll merge this as is, with the expectation that we are likely to change it in the non-MVP

kitlith commented 1 year ago

I haven't looked at your followup non-MVP version, but I would expect this can be fixed it there by having two traits - one for describing native openvr storage types, and one trait for generically getting those into rust types.

For now, I'll merge this as is, with the expectation that we are likely to change it in the non-MVP

This change is completely orthogonal to the non-MVP version (even though I'll have to update it due to the lifetimes strewn about because of this PR). Non-MVP is entirely about tying specific properties to specific types, to make it so that you cannot mistakenly query a string property as a uint64, for example.