Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bryceco/fastcodable.old
Simple binary serialization for Swift
https://github.com/bryceco/fastcodable.old
Last synced: 15 days ago
JSON representation
Simple binary serialization for Swift
- Host: GitHub
- URL: https://github.com/bryceco/fastcodable.old
- Owner: bryceco
- Created: 2023-04-03T01:28:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-09T01:08:54.000Z (over 1 year ago)
- Last Synced: 2024-05-16T07:12:56.668Z (6 months ago)
- Language: Swift
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastCodable
A fast encoding/decoding library for Swift.
* Minimal, extensible implementation of binary object serialization.
* Not a drop-in replacement for Codable. You must add your own conformance to the protocol.
* Does not support endianness, so not suitable for transfering data between different architectures.
* Supports most standard types: Int, Double, String, Array, Dictionary, Optional
* Around 10x faster (in Release builds) than keyed coding solutions like JSONEncoder, PropertyListEncoder, etc.```
struct Test: FastCodable {
var a: Int
var b: String?
var c: [Double]init(fromFast decoder: FastDecoder) throws {
a = try decoder.decode()
b = try decoder.decode()
c = try decoder.decode()
}func fastEncode(to encoder: FastEncoder) {
a.fastEncode(to: encoder)
b.fastEncode(to: encoder)
c.fastEncode(to: encoder)
}
}var test: Test()
let buffer: Data = FastEncoder.encode(input)
let output = try FastDecoder.decode(Test.self, data: buffer)
assert(test == output)
```