ManageIQ / ManageIQ/binary_struct

Supporting bit decoding and encoding

Open
#14 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue help wanted pinned size/m
Dominant language
Ruby
Stars
5
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the BinaryStruct.decode, encode, and size entry points and inspect how format identifiers are currently parsed and packed. Define support for successive bit fields with optional padding and byte alignment, then verify that decoding, encoding, and size calculation agree for the structures shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.