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

Make bytes dependency optional #52

Merged
merged 4 commits into from
Feb 12, 2025
Merged

Make bytes dependency optional #52

merged 4 commits into from
Feb 12, 2025

Conversation

jklmnn
Copy link
Contributor

@jklmnn jklmnn commented Feb 6, 2025

ref #51

@00imvj00
Copy link
Owner

00imvj00 commented Feb 7, 2025

@jklmnn Builds are failing, here is the error. please check?
Screenshot 2025-02-07 at 2 19 20 PM

@jklmnn
Copy link
Contributor Author

jklmnn commented Feb 7, 2025

The problem seems to be that bytes are used in the tests and are not available with no_std. We could either add it as a test dependency or modify the tests to work without it (which I would prefer since we want to check that it works without it).

There are 2 instances I have identified so far. The first one is the one in your screenshot. Here I'm not sure what the intention is.

let mut data = bm(&[
is the only use of bytes in decoder_test. Since the test input is the same for the version with and without bytes my guess is that it is intended. I made this test dependent on std which seems to fix it.

The other problems are the examples. E.g.

/// # use mqttrs::*;
. We either have to adapt them to work without bytes or make them work without it. Since the only reason for bytes here seems to be the test data (and the example on how to use bytes with the API) I think we could remove them. But I don't have a really strong opinion on that.

I haven't looked into how bytes is used internally. From a users perspective I found the bytes reference in the documentation rather confusing since it doesn't seem to be required for it to work. If you want I can remove bytes from the examples but this is really a design decision. If you want to keep bytes in them I think we have to disable the examples for the no_std tests.

@mchodzikiewicz
Copy link
Contributor

You can disable doctests for specific cfg like this: https://users.rust-lang.org/t/how-to-disable-documentation-testing-for-specific-platforms/5059

@jklmnn
Copy link
Contributor Author

jklmnn commented Feb 7, 2025

@mchodzikiewicz I have disabled the doc tests in the workflow itself by running them with --tests --lib.

@00imvj00 the tests should work now. I have also added a check running cargo fmt and formatted the code with it. Let me know if that is okay for you.

@00imvj00 00imvj00 merged commit dd9d381 into 00imvj00:master Feb 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants