Skip to content

Commit 49a5669

Browse files
committed
Updated README
Removed unneeded go.sum
1 parent f6fade2 commit 49a5669

File tree

2 files changed

+16
-39
lines changed

2 files changed

+16
-39
lines changed

README.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Schemer seeks to be an alternative to [protobuf](https://github.com/protocolbuff
2020

2121
## Why?
2222

23-
Schemer is an attempt to further simplify data encoding. Unlike other encoding libraries that use [interface description languages](https://en.wikipedia.org/wiki/Interface_description_language) (i.e. protobuf), schemer allows developers to construct schemata programmatically with an API. Rather than generating code from a schema, a schema can be constructed from code. In Go, schemata can be generated from Go types using the reflection library. This subtlety adds a surprising amount of flexibility and extensibility to the encoding library.
23+
Schemer is an attempt to further simplify data encoding. Unlike other encoding libraries that use [interface description languages](https://en.wikipedia.org/wiki/Interface_description_language) (i.e. protobuf), schemer allows developers to construct schemata programmatically with an API. Rather than generating code from a schema, a schema can be constructed from code. In Go, schemata can be generated from Go types using the reflection library. This adds a surprising amount of flexibility and extensibility to the encoding library.
2424

2525
Here's how schemer stacks up against other encoding formats:
2626

27-
| Property | JSON | XML | MessagePack | Protobuf | Thrift | Avro | Gob | Schemer |
27+
| Property | JSON | XML | MessagePack | Protobuf | Thrift | Avro | Gob | *Schemer* |
2828
| -------------------------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
2929
| Human-Readable | :heavy_check_mark: | :neutral_face: | :x: | :x: | :x: | :x: | :x: | :x: |
3030
| Support for Many Programming Languages | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: |
@@ -40,14 +40,16 @@ Here's how schemer stacks up against other encoding formats:
4040
| Supports Fixed-field Objects | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
4141
| Works on Web Browser | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :neutral_face: | :heavy_check_mark: | :x: | :calendar: soon… |
4242

43+
The table above is intended to guide the reader toward an encoding format based on their requirements, but the evaluations of these encoding formats are, of course, rather subjective. Please feel free to open an issue if you feel something should be adjusted and/or corrected.
44+
4345
## Types
4446

4547
schemer uses type information provided by the schema to encode values. The following are all of the types that are supported:
4648

4749
- Integer
4850
- Can be signed or unsigned
4951
- Fixed-size or variable-size [^1]
50-
- Fixed-size integers can be 8, 16, 32, 64, or 128 bits
52+
- Fixed-size integers can be 8, 16, 32, or 64 bits
5153
- Floating-point number (32 or 64-bit)
5254
- Complex number (64 or 128-bit)
5355
- Boolean
@@ -73,7 +75,7 @@ schemer uses type information provided by the schema to encode values. The follo
7375

7476
| Type | JSON Type Name | Additional Options |
7577
| ------------------------ | -------------- | ------------------------------------------------------------ |
76-
| Fixed-size Integer | int | * `signed` - boolean indicating if integer is signed or unsigned<br />* `bits` - one of the following numbers indicating the size of the integer: 8, 16, 32, 64, 128, 256, 512, 1024 |
78+
| Fixed-size Integer | int | * `signed` - boolean indicating if integer is signed or unsigned<br />* `bits` - one of the following numbers indicating the size of the integer: 8, 16, 32, 64, 128, 256, 512, 1024<br />Note: integers larger than 64 bits are not fully supported |
7779
| Variable-size Integer | int | * `signed` - boolean indicating if integer is signed or unsigned<br />* `bits` - must be `null` or omitted |
7880
| Floating-point Number | float | * `bits` - one of the following numbers indicating the size of the floating-point: 32, 64 |
7981
| Complex Number | complex | * `bits` - one of the following numbers indicating the size of the complex number: 64, 128 |
@@ -111,7 +113,7 @@ Here's a struct with three fields:
111113
"name": "age",
112114
"type": "int",
113115
"signed": false,
114-
"size": 1
116+
"bits": 8
115117
}
116118
]
117119
}
@@ -121,7 +123,7 @@ Here's a struct with three fields:
121123

122124
When decoding values from one type to another, schemer employs the following compatibility rules. These rules, while rather opinionated, provide safe defaults when decoding values. Users who want to carefully craft how values are decoded from one type to another can simply create a custom type.
123125

124-
As a general rule, types are only compatible with themselves (i.e. boolean values can only be decoded to boolean values). The table below outlines a few notable exceptions and describes how using "weak" decoding mode can increase type compatibility by sacrificing type safety and by making a few assumptions.
126+
As a general rule, types are only compatible with themselves (i.e. boolean values can only be decoded to boolean values). The table below outlines a few notable exceptions and describes how using "weak" decoding mode can increase type compatibility by sacrificing type safety and by making a few assumptions.
125127

126128
| | Destination | | | | | | | |
127129
| --------------- | --------------------- | --------------------- | ---------------------- | ---------------------- | --------------------- | ---------------------- | ---------------------- | --------------------- |
@@ -135,7 +137,7 @@ As a general rule, types are only compatible with themselves (i.e. boolean value
135137
| array (see #12) | :x: | :x: | :grey_exclamation: #11 | :x: | :x: | :x: | :heavy_check_mark: #3 | :x: |
136138
| object | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: #4 |
137139

138-
**Legend**:<br/>:heavy_check_mark: - indicates compatibility according to the specified rule<br/>:grey_exclamation:- indicates compatibility according to the specified rule only if weak decoding is used<br/>:x: - indicates that the source type cannot be decoded to the destination
140+
**Legend**:<br/>:heavy_check_mark: - indicates compatibility according to the specified rule<br/>:grey_exclamation:- indicates compatibility according to the specified rule only if weak decoding is used<br/>:x: - indicates that the source type cannot be decoded to the destination (excepting rule #12)
139141

140142
#### Compatibility Rules:
141143

@@ -163,13 +165,13 @@ The following compatibility rules apply for weak decoding only:
163165

164166
#### String to number decoding:
165167

166-
| String Example | Regular Expression | Decoded As |
167-
| -------------- | ------------------ | ----------------------- |
168-
| `"-3.14"` | | Number, base 10 |
169-
| `"0b1101"` | | Number, base 2 |
170-
| `"0775"` | | Number, base 8 |
171-
| `"0x2020"` | | Number, base 16 |
172-
| `"2.34 + 2i"` | | Complex number, base 10 |
168+
| String Example | Decoded As | Regular Expression |
169+
| -------------- | ----------------------- | ------------------------------------------------------------ |
170+
| `"-3.14"` | Number, base 10 | `^[-+]?(0|[1-9][0-9]*)(\.[0-9]*)?([eE][+-]?[0-9]+)?$` |
171+
| `"0b1101"` | Integer, base 2 | `^[-+]?0[bB][01]+$` |
172+
| `"0775"` | Integer, base 8 | `^[-+]?0[oO]?[0-7]+$` |
173+
| `"0x2020"` | Number, base 16 | `^[-+]?0[xX][0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([pP][+-]?[0-9A-Fa-f]+)?$` |
174+
| `"2.34 + 2i"` | Complex number, base 10 | You don't want to see it, but here's [the link](https://regexper.com/#%5E%5B-%2B%5D%3F%280%7C%5B1-9%5D%5B0-9%5D*%29%28%5C.%5B0-9%5D*%29%3F%28%5BeE%5D%5B%2B-%5D%3F%5B0-9%5D%2B%29%3F%28%5Cs*%5B-%2B%5D%5Cs*%280%7C%5B1-9%5D%5B0-9%5D*%29%28%5C.%5B0-9%5D*%29%3F%28%5BeE%5D%5B%2B-%5D%3F%5B0-9%5D%2B%29%3F%29%3Fi%24). |
173175

174176
## Credits
175177

go.sum

-25
This file was deleted.

0 commit comments

Comments
 (0)