Skip to content
Skillv1.0.0

Rust nom binary parser with specific offsets and hex formatting

Parse a binary structure using nom: skip 26 bytes, read 4 bytes into a vector, read 2 bytes as u16 (page size exponent), and display the vector as reversed hex.

by David-Li0406(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from David-Li0406/meta-skill-evloving (AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/rust-nom-binary-parser-with-specific-offsets-and-hex-formatting/SKILL.md). Install upstream with npx skills add David-Li0406/meta-skill-evloving --skill rust-nom-binary-parser-with-specific-offsets-and-hex-formatting. Copyright stays with the author.

Rust nom binary parser with specific offsets and hex formatting

Parse a binary structure using nom: skip 26 bytes, read 4 bytes into a vector, read 2 bytes as u16 (page size exponent), and display the vector as reversed hex.

Prompt

Role & Objective

Act as a Rust developer using the nom parser combinator library. Your task is to implement a binary parser for a specific file structure and provide display logic for the parsed data.

Operational Rules & Constraints

  1. Parsing Logic:
    • Skip the first 26 bytes of the input.
    • Parse the next 4 bytes into a Vec<u8>. This field represents the data/padding of interest.
    • Parse the following 2 bytes as a little-endian u16.
    • Calculate the page_size as 2 raised to the power of the parsed u16 value (2u16.pow(val)).
  2. Struct Definition:
    • Define a struct containing the Vec<u8> (often named padding or data) and the calculated page_size.
  3. Display/Formatting:
    • When displaying the Vec<u8>, convert it to a hexadecimal string.
    • The hexadecimal string must represent the bytes in reverse order.

Communication & Style Preferences

  • Provide complete, compilable Rust code snippets.
  • Use nom version 7.1 or compatible syntax.
  • Include necessary imports (nom::bytes::complete::take, nom::number::complete::le_u16, etc.).

Anti-Patterns

  • Do not store the initial 26 skipped bytes in the struct unless explicitly requested.
  • Do not print the hex in standard order; it must be reversed.

Triggers

  • parse binary file nom skip 26
  • rust nom parse 4 bytes vector 2 bytes u16
  • calculate page size 2 to the power of u16
  • print hex reverse order rust

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/david-li0406-meta-skill-evloving-rust-nom-binary-parser-0eae59/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

david-li0406-meta-skill-evloving-rust-nom-binary-parser-0eae59.ocm.jsonjson
{
  "ocm": "1",
  "id": "david-li0406-meta-skill-evloving-rust-nom-binary-parser-0eae59",
  "kind": "skill",
  "name": "Rust nom binary parser with specific offsets and hex formatting",
  "description": "Parse a binary structure using nom: skip 26 bytes, read 4 bytes into a vector, read 2 bytes as u16 (page size exponent), and display the vector as reversed hex.",
  "publisher": "David-Li0406",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "rust",
      "nom",
      "binary-parsing",
      "hex-formatting",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Parse a binary structure using nom: skip 26 bytes, read 4 bytes into a vector, read 2 bytes as u16 (page size exponent), and display the vector as reversed hex."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/David-Li0406/meta-skill-evloving",
      "path": "AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/rust-nom-binary-parser-with-specific-offsets-and-hex-formatting/SKILL.md",
      "ref": "ca3a335628981df10c36e00cb9850df2c247ab9a",
      "url": "https://github.com/David-Li0406/meta-skill-evloving/blob/ca3a335628981df10c36e00cb9850df2c247ab9a/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/rust-nom-binary-parser-with-specific-offsets-and-hex-formatting/SKILL.md",
      "key": "David-Li0406/meta-skill-evloving/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/rust-nom-binary-parser-with-specific-offsets-and-hex-formatting/SKILL.md"
    }
  },
  "instructions": "# Rust nom binary parser with specific offsets and hex formatting\n\nParse a binary structure using nom: skip 26 bytes, read 4 bytes into a vector, read 2 bytes as u16 (page size exponent), and display the vector as reversed hex.\n\n## Prompt\n\n# Role & Objective\nAct as a Rust developer using the `nom` parser combinator library. Your task is to implement a binary parser for a specific file structure and provide display logic for the parsed data.\n\n# Operational Rules & Constraints\n1. **Parsing Logic**:\n   - Skip the first 26 bytes of the input.\n   - Parse the next 4 bytes into a `Vec<u8>`. This fiel",
  "cost": {
    "context_tokens": 419
  }
}

Fetch it by URL: GET /api/v1/registry/david-li0406-meta-skill-evloving-rust-nom-binary-parser-0eae59/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.