-
Notifications
You must be signed in to change notification settings - Fork 149
BREAKING: use Cow<'static, CStr> for string argument
#799
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
base: master
Are you sure you want to change the base?
Conversation
feb1938 to
7b95abf
Compare
2274812 to
4504d53
Compare
|
If arguments take Perhaps a custom trait like Rustix uses would be best here: https://docs.rs/rustix/1.0.3/rustix/path/trait.Arg.html. |
|
In principle using |
|
There is also the issue that strings in Wayland are rather undefined in their use. Nothing stops a client from sending you malformed UTF-8 or UTF-16. The two exceptions are xdg-toplevel titles (explicitly defined as UTF-8) and the identifier the compositor created for ext-foreign-toplevel-handle (printable ASCII) |
|
Right. As defined in https://wayland.freedesktop.org/docs/html/ch04.html, I guess technically the only difference between strings and arrays is null-termination? And this seems to imply there shouldn't be other nul bytes, though I don't see that explicitly mentioned. So |
12c8ae7 to
7ff83c6
Compare
|
@ids1024 |
|
Yeah, there's not a clear best way to do this. Converting a |
|
I will also note that the Wayland protocol defines a string argument as:
We need the null terminator, but it's not necessarily used for counting the string's length. That's something C-based Wayland clients can do. And here's a note in CStr's documentation on count_bytes:
It would be better to take a |
|
Recent versions of the core Wayland protocol will also require that all strings used are valid UTF-8: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/387 |
|
Correction: |
Closes #748.
Leave construction of string argument to caller and make
ffiprocess less panic-proned, and is benefit for users whose rust version is above 1.77 to use C-string literals