swift-binary-coder

main

Flat, untagged binary serializer for Codable Swift types
fwcd/swift-binary-coder

Binary Coder for Swift

Build Docs

A simple Encoder and Decoder that serializes Codable Swift types to a flat, untagged binary representation. Note that this usually requires the structures to have a fixed size.

Example

struct Point: Codable {
    let x: UInt16
    let y: UInt16
}

let encoder = BinaryEncoder()
try encoder.encode(Point(x: 2, y: 3))
// -> Data([0, 2, 0, 3])

let decoder = BinaryDecoder()
try decoder.decode(Point.self, from: Data([0, 2, 0, 3]))
// -> Point(x: 2, y: 3)

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Sun Jan 07 2024 02:45:19 GMT-1000 (Hawaii-Aleutian Standard Time)