Gnurou / v4l2r

Rust bindings for V4L2
MIT License
21 stars 10 forks source link

lib: add v4l2_frmivalenum safe accessor to union #21

Closed aesteve-rh closed 11 months ago

aesteve-rh commented 11 months ago

Add an accessor for v4l2_frmivalenum anonymous union members, avoiding having to write the union name and safely returning the appropriate member of the union that is used.

aesteve-rh commented 11 months ago

@Gnurou This is just a proposal, I wanted to know your opinion before doing this for other structs.

The idea is to allow a more friendly name for accessing the union members, as for an anonymous struct/union, bindgen gives some arguably ugly names. Also, improves the safety of using the structs, as only the member of the struct that gets initialized by the driver is returned (based on the index).

Gnurou commented 11 months ago

Thank you! Yes, we need more of these safe accessors for the bindings. I'm happy to merge this, but please see the inline comments for a couple of nits.

aesteve-rh commented 11 months ago

Thanks for the feedback!

I've addressed all your comments, did the same for frmsizes, and will ready the PR up.

Gnurou commented 11 months ago

Thank you! It's perfect. :+1: