Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Wrong signature for gio::content_type_guess #1257

Open
Schmiddiii opened this issue Dec 24, 2023 · 3 comments
Open

[BUG] Wrong signature for gio::content_type_guess #1257

Schmiddiii opened this issue Dec 24, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Schmiddiii
Copy link

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.

@Schmiddiii Schmiddiii added the bug Something isn't working label Dec 24, 2023
@sdroege
Copy link
Member

sdroege commented Dec 24, 2023

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.

@Schmiddiii
Copy link
Author

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).

@euclio
Copy link
Contributor

euclio commented Dec 24, 2023

Related: gtk-rs/gir#1133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants