gtk-rs-core
gtk-rs-core copied to clipboard
[BUG] Wrong signature for `gio::content_type_guess`
Bug description
The signature of gio::content_type_guess has the type of data as &[u8]. The same documentation, and also the gio documentation mention that data can be None. So a better signature would set data to Option<&[u8]> or similar. Note that the current signature can lead to wrong results if one wants the content type to be guessed only based on the filetype, this is not possible based on the current signature.
This change would be breaking.
It looks like currently all array-like nullable parameters are not optional. Passing &[] might or might not do what you want, but this should probably be fixed and be made more explicit. It's also not guaranteed that empty / NULL give the same behaviour.
This would need a change in the code generator.
Pretty sure None and &[] are not the same for this function, passing &[] is interpreted as "empty file" and leading to application/x-empty (at least in one case I had, it worked for one other case. Not sure what the exact rules are).
Related: https://github.com/gtk-rs/gir/issues/1133