-
Notifications
You must be signed in to change notification settings - Fork 11
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
PR containing many things #28
Conversation
Great. I see that it does fail some linting tests :)) That one with the len is pretty hilarious. You can maybe explicitly ignore all the warnings(with #[allow(...)]) |
Yeah I will get to those linter warnings in the next commit. Just thought I might as well get some feedback on the existing stuff and bundle those things together. |
I think the The builder pattern for a buffer is I think unnecessary. Maybe we can just pass a config either in Also, I would separate sync bytes from addresses(like passing in an array of sync bytes(of type These are just some things that I would change but if you think we should leave them as they are, that's still fine by me. Other than that, everything seems great and thank you for your contribution :)) |
I can try to make My reasoning for I agree the builder pattern is maybe a bit much for just 2 configurables. I would be okay with just supplying a config, so we have I would also like to separate the concepts of sync bytes and addresses, but that would just make the bitflag approach not work, since that relies on the relatively small number of addresses vs 256 different values in a byte. We could also have a heapless::Vec of u8 of some fixed length, e.g. |
A solution would be to specify the config on every call and we could store the slice in the config struct with a lifetime. (I don't think this is such a good solution)
👍 |
We also could take in a static slice of sync bytes. It might fit better into an embedded application |
I think it's a matter of taste. For our simple case I would prefer a config. But a builder is also OK, possibly later there will be more configuration parameters. I often see configuration pattern in embedded programming, particularly in Embassy. |
I also thought about storing a static array of addresses as there are only 14 items. But then @peterkrull suggested to use |
@peterkrull Could you add a method to |
Me too, but the builder is a nice way to abstract away the conversion from
We could do that, but since |
One point to a builder is that adding new method won't break a user code. With a config adding new field is a breaking change. |
Yeah, we definitely can live without it but it is not a very convenient way especially because we have to deal with error handling: raw_packet.addr()
// vs
PacketAddress::try_from(raw_packet.as_slice()[0]).unwrap() |
Hey! What's the status on your PR? |
Most of the stuff we already talked about in #27, but I will list the major things here again.
push_bytes
now may return a reference to theRawPacket
used as a buffer within the PacketReader. This can be cloned as the user sees fit.push_bytes
now also returns whichever errors are encountered. We use a "digest" style for the CRC, but not using the Crc library. Apparantly the Digest itself is consumed whenever it is finalized, making it a bit more awkward to work with. This custom method works well.I have not had the extended format too much in mind with all this, so some things will obviously need modification after the fact.