wayland-rs icon indicating copy to clipboard operation
wayland-rs copied to clipboard

No way to identify an Event's variant.

Open xaltsc opened this issue 3 years ago • 2 comments

In the previous versions, it was possible to retrieve the opcode from an Event with the MessageGroup trait. The latest beta version (0.30.0-beta.8) doesn't allow to do so.

Moreover, the fact that Events are single standing structs without a shared type/trait makes it lose in genericity compared to the last stable version.

xaltsc avatar Aug 04 '22 11:08 xaltsc

Needing to work with opcodes directly is imo a strong hint that you might want to use the lower-level interface ObjectData from wayland-backend, maybe?

What is your need?

elinorbgr avatar Aug 07 '22 00:08 elinorbgr

I'm just storing information given by the events (think those of WlOutput for instance) in an array/HashMap.

Right now, I have to manually declare a key associated to each variant in order to make the HashMap behave like a set, whereas, with the latest stable version, I could just use a fixed-size array (with size that of the MessageGroup's event), and use the event's numerical id as the key.

xaltsc avatar Aug 08 '22 15:08 xaltsc

Well, that an uncommon way of handling events. But I suppose adding an fn opcode(&self) -> u16 method to the code generated by the scanner is not a big deal anyway.

elinorbgr avatar Aug 25 '22 08:08 elinorbgr

Out of curiosity, how would you manage events ? Without further assumption on use, proxy type, etc, just as a source of information to be queried later.

xaltsc avatar Sep 02 '22 01:09 xaltsc

Without further assumption on use, proxy type, etc, just as a source of information to be queried later.

Well, that is in itself, a pretty uncommon way to handle events. Most client interpret the event content as soon as it is received and store relevant information in specialized structs. From what you're saying your use-case does not fit "most clients", so that's kinda difficult to tell without knowing more about what you're trying to do.

elinorbgr avatar Sep 02 '22 10:09 elinorbgr