Closed FeldrinH closed 3 months ago
Hi, thanks for the issue. I'm gonna reproduce it on my end, and it should be fixed soon. Did you test against the crates.io release or master? There were severe changes in that region, completely removing the type representations, greatly simplifying this API. I'll release a new version, once VHT is done.
I tested 0.2.2 from crates.io. Latest master did not compile.
Oh yeah, I accidentally pushed the module declaration, before the module was done. This will be fixed in a few minutes, because I'm just finishing up the VHT elements.
Just pushed VHT support and CI goes through now. Sorry for the chaos.
Currently away from my computer, but looking at the code the lifetime handling of elements hasn't changed much, so master should have the same issue.
Yeah it has, I'm working on it rn.
This should've been fixed by the latest commit. The solution is (surprisingly), to just use self
instead of &self
, which makes absolutely no difference performance wise, since ReadElements
is just a slice internally. I added a test, for this. Let me know, if this resolved the issue for you.
The issue with elements does seem to be fixed. ProbeRequestBody.ssid
and BeaconLikeFrameBody.ssid
also have a similar problem and there might be some more that I have missed. For those two it should be as simple as replacing &'a self
with &self
to decouple the borrow from the lifetime of the returned value.
I pushed another commit, which also resolves this for the SSID. Thanks a lot for helping catch this. This was my first real issue, apart from an incorrectly declared module and it makes me really happy to see someone use my library. I hope it's doing its job otherwise.
Haven't done any heavy testing as I only need a couple of vendor specific elements from beacon and action frames, but so far it has been working fine. I wish you luck, the 802.11 standard is huge, but having a reliable and fast dissector in Rust is valuable.
Thanks, love to hear that. I wish you good luck, with your project, as well. I'm gonna close this issue as completed.
Since all the frame and element types have an explicit lifetime parameter, I was hoping that I could write a function that takes a reference to bytes and return a reference to an element. Something like this:
Unfortunately this does not compile, because the lifetime of the element is for some reason tied to the lifetime of
beacon.elements
itselt, not the bytes contained within. Compiler error:I believe the problem starts with this signature:
For my snippet to work the lifetime of
&self
should not be tied to'a
:Taking a quick look at the code, it seems that the problem is relatively pervasive. A number of other functions also have the same issue or something similar. It would be nice if this could be fixed, to make the library more flexible.
PS: Taking a quick look at the code, it seems to me that this should be fixable simply by tweaking some lifetime parameters, with no other changes necessary.