https://github.com/DanSnow/crystal-binary_parser
Binary parser for Crystal
https://github.com/DanSnow/crystal-binary_parser
binary-parser crystal crystal-binary-parser
Last synced: 9 months ago
JSON representation
Binary parser for Crystal
- Host: GitHub
- URL: https://github.com/DanSnow/crystal-binary_parser
- Owner: DanSnow
- License: mit
- Created: 2016-12-10T14:50:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-13T01:17:30.000Z (almost 4 years ago)
- Last Synced: 2025-03-16T16:39:10.243Z (9 months ago)
- Topics: binary-parser, crystal, crystal-binary-parser
- Language: Crystal
- Size: 64.5 KB
- Stars: 18
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - crystal-binary_parser - Binary parser (Misc)
- awesome-crystal - crystal-binary_parser - Binary parser (Misc)
- awesome-crystal - crystal-binary_parser - Binary parser (Misc)
README
crystal-binary_parser
=====================
[](https://circleci.com/gh/DanSnow/crystal-binary_parser)
[](https://github.com/DanSnow/crystal-binary_parser/releases)
Description
-----------
A binary parser for crystal.
Requirement
-----------
- crystal >= 0.20.0
Install
-------
Add this to your `shard.yml`
```yml
dependencies:
binary_parser:
github: DanSnow/crystal-binary_parser
```
Feature
-------
- Parse and write binary file
- Support array (fixed size or variable size)
- Support string (fixed length or valirable length)
- Support nested parser
- Support config which endian to use
- Calculate byte size
Usage
-----
```crystal
require "binary_parser"
class Parser < BinaryParser
uint8 :foo
end
# Load a file
parser = Parser.new
parser.load("")
# Or from IO
io = File.open("")
parser = Parser.new
parser.load(io)
# Now you can get your data
puts parser.foo
```
License
-------
MIT