2020-04-17 14:32:43 +02:00
|
|
|
# CBOR
|
|
|
|
|
2020-04-19 13:55:23 +02:00
|
|
|
[![builds.sr.ht status](https://builds.sr.ht/~arestifo/crystal-cbor.svg)](https://builds.sr.ht/~arestifo/crystal-cbor?)
|
|
|
|
|
2020-04-17 14:32:43 +02:00
|
|
|
This library implements the [RFC7049: Concise Binary Object Representation (CBOR)][rfc]
|
|
|
|
in Crystal.
|
|
|
|
|
2020-04-23 09:41:46 +02:00
|
|
|
## Features
|
|
|
|
|
|
|
|
- Full support for diagnostic notation
|
2020-04-24 00:05:50 +02:00
|
|
|
- Assign a field to a type base on the CBOR tag
|
|
|
|
- Support for a wide range of IANA CBOR Tags
|
2020-04-23 09:41:46 +02:00
|
|
|
|
2020-04-22 22:31:00 +02:00
|
|
|
## Limitations
|
|
|
|
|
2020-04-24 00:05:50 +02:00
|
|
|
### Half-precision floating point is not supported
|
|
|
|
|
|
|
|
Crystal doesn't have a `Float16` type, so half-precision floating point numbers
|
|
|
|
are not supported for the time being.
|
|
|
|
|
2020-04-24 11:37:41 +02:00
|
|
|
If you know of a way to solve handle half-precision float, a contribution would
|
|
|
|
be really appreciated.
|
|
|
|
|
2020-04-22 22:31:00 +02:00
|
|
|
### Maximum Array/String array/Bytes array length
|
|
|
|
|
|
|
|
The spec allows for the maximum length of arrays, string arrays and bytes array
|
|
|
|
to be a `UInt64`.
|
|
|
|
|
|
|
|
While this library supports lengths expressed as a `UInt64`, it must not exceed
|
|
|
|
`Int32::MAX`.
|
|
|
|
|
2020-04-17 14:32:43 +02:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
1. Add the dependency to your `shard.yml`:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
dependencies:
|
|
|
|
cbor:
|
2020-04-19 14:05:27 +02:00
|
|
|
git: https://git.sr.ht/~arestifo/crystal-cbor
|
2020-04-17 14:32:43 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
2. Run `shards install`
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```crystal
|
|
|
|
require "cbor"
|
|
|
|
```
|
|
|
|
|
|
|
|
TODO: Write usage instructions here
|
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
TODO: Write development instructions here
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
1. Fork it (<https://github.com/your-github-user/cbor/fork>)
|
|
|
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
|
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
|
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
|
|
5. Create a new Pull Request
|
|
|
|
|
|
|
|
## Contributors
|
|
|
|
|
|
|
|
- [Alberto Restifo](https://github.com/your-github-user) - creator and maintainer
|
|
|
|
|
|
|
|
[rfc]: https://tools.ietf.org/html/rfc7049
|