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

Supporting bit decoding and encoding #14

Open
Fryguy opened this issue Mar 5, 2020 · 1 comment
Open

Supporting bit decoding and encoding #14

Fryguy opened this issue Mar 5, 2020 · 1 comment

Comments

@Fryguy
Copy link
Member

Fryguy commented Mar 5, 2020

I'd like to specify the following:

BinaryStruct.decode([
  'L', :some_num,
  'b', :flag1,
  'b', :flag2,
  'b', :flag3,
  'L', :another_num,
])

Given that, I'd expect BinaryStruct.decode to extract a number, then on the next byte extract the first 3 bits as booleans stored in :flag1, :flag2, :flag3, then move ahead to the next byte and extract another number.

I'd probably be happy with having to align my definition to byte boundaries, so perhaps...

BinaryStruct.decode([
  'L', :some_num,
  'b', :flag1,
  'b', :flag2,
  'b', :flag3,
  'b5', :unused, # ideally optional
  'L', :another_num,
])

I would expect encode and size to handle similar structures.


Implementation wise, the 'b' identifier reads 1 bit then skips to the next byte, So, when building the decode string it will have to be aware of successive bits and then pack those into a b8.

@miq-bot
Copy link
Member

miq-bot commented Jun 11, 2020

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants