Latest 1.0.0
Homepage https://github.com/bearyinnovative/MessagePack
License MIT
Platforms ios 10.0, requires ARC
Authors

MessagePack for Swift

Swift implementation for MessagePack.

Packing

protocol Packable {
    func packToBytes() -> Bytes
    func pack() -> Data
}

Packable stdlib types:

  • Bool, Double, Int, UInt, Int64, UInt64
  • Optional where Wrapped : Packable
  • Array where Element: Packable
  • Dictionary where Key: Hashable, Key: Packable, Value: Packable

Packable extended types:

  • Binary
  • Extension

If you want to pack data with mixed types, use ValueBox.

Unpacking

struct Unpacker {
    static func unpack(bytes: Bytes) -> ValueBox?
}

Unpack from data, conveniences for Unpacker.unpack(bytes:):

extension Data {
    func unpack() -> ValueBox?
}

Unpackable stdlib types contains:

  • Bool
  • Double
  • Float
  • Int
  • Int64
  • String
  • UInt
  • UInt64

For other mixed types, you can alway use ValueBox instead.

enum ValueBox {
    case array([ValueBox])
    case binary(Binary)
    case bool(Bool)
    case dictionary([ValueBox: ValueBox])
    case double(Double)
    case `extension`(Extension)
    case float(Float)
    case int64(Int64)
    case `nil`
    case string(String)
    case uint64(UInt64)
}

Latest podspec

{
    "name": "MessagePackSwift",
    "version": "1.0.0",
    "summary": "Swift implementation for MessagePack.",
    "homepage": "https://github.com/bearyinnovative/MessagePack",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "bearyinnovative": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/bearyinnovative/MessagePack.git",
        "tag": "v1.0.0"
    },
    "requires_arc": true,
    "source_files": "Sources/CommonDigest"
}

Pin It on Pinterest

Share This