-
Notifications
You must be signed in to change notification settings - Fork 38
Add core friendly, no_std, no result, Read/Write trait and/or api #7
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
Comments
What is the difference between trait pread and cread? They look the same to me. |
The short story:Pread returns Cread returns The long story:Pread uses the conversion trait Cread uses the conversion trait If you peak in the file
I realize now that I can move the indexing logic into the Pread trait itself via bounds, assume for |
Oh yeah, gotcha. Something want to sayAwesome Work !!! I can tell this crate is so generic to work in many domain, especially in low level networking and hardware communication, while for byte parsing job, the crate You could advertise your work to let other's know. AFAIK, here and here are the right place. Anyway, I can see there are rough edges on API designs.
|
@goandylok Thanks for the kind words, that's very nice of you to say, and glad it could help :) And wow seems like you've definitely investigated the source. So the assert's went into I think it is fixable in For second point, i'm not quite sure I understand. The SizeWith is basically just If you have any suggestions or issues, please feel free to raise and issue and we can work on it :) |
I have two solutions for the first topic:
I will choose to use For the second topic, maybe I misunderstood |
I typed up an enormous response on my phone and then githubrefreshed somehow and deleted everything so that's cool. The short response is that SizeWith doesn't take self, and Gread is totally generic and requires knowing the size of the type beforehand to parse and increment the offset or return an error. SizeWith is intentionally not implemented for &str currently (or Uleb128) to force users to think about how to automatically update the offset when variable length data is present in the bytes, which usually requires specifying the size in the context, or just giving up and using pread for the slices and incrementing the offset manually. I did consider adding a MeasureWith trait that does take self and adding a read that does this for you, but need to think about it |
This is on master now; I actually think I may release new crate version as is soon; but i may want to get #10 done before that, not sure, maybe wait until after, since it will potentially be a big change |
So I think this is done actually, and I think I want to push out a crate for 0.7.0 exposing the new api. I wish it was easier to test no_std setups :/ |
This is done |
Example
Current working draft is on a branch, core_api, and basically lets you do this:
All the basic numeric types are supported, and anything that implements
FromCtx
(which is much easier to understand and implement than it's evil cousin,TryFromCtx
), will automatically be deseriablizable without result oriented api via:as show above in the example.
Yay!
Some considerations
I'm partial to 2., since it doesn't require adding another trait as an import; but then again, perhaps who cares?
Of the maybe 1 or 2 people paying attention, any opinions welcome. 😎
The text was updated successfully, but these errors were encountered: