EventContext Lifetime Makes It Impossible to Store
Opened this issue · 0 comments
Hi,
mpv::create_event_context
returns an EventContext<'a>
with the lifetime of the Mpv
instance. While this works fine as long as this event context is only used in the function it is created in (such as in your examples), this makes it impossible to store the event context in a struct that also contains the Mpv
instance (since you can't have a lifetime referencing something within the same struct in Rust). You also can't create a new EventContext<'a>
every time you need it, since there's this atomic boolean to make sure that only once instance is ever created.
What is the reason why EventContext
isn't simply held in the Mpv instance and only ever returned by reference in a getter? This way its lifetime also can never exceed the Mpv instance's lifetime, and you don't even have to do the whole atomic boolean dance.