kmsquire/MsgPack.jl — pull request #7 by Sean1708 (2014-12-30 00:08:37+00:00)
Title: Extension types.

I needed extension types so I whipped up a quick implementation of them. Extensions are packed from and unpacked into an `Ext` immutable which simply stores the typecode and data. The constructor limits the value of the type code as given in the spec.

```julia
julia> using MsgPack

julia> a = Ext(35, Uint8[1, 2, 3, 4, 5, 6])
MsgPack.Ext(35,UInt8[0x01,0x02,0x03,0x04,0x05,0x06])

julia> b = pack(a)
9-element Array{UInt8,1}:
0xc7
0x06
0x23
0x01
0x02
0x03
0x04
0x05
0x06

julia> c = unpack(b)
MsgPack.Ext(35,UInt8[0x01,0x02,0x03,0x04,0x05,0x06])

julia> a == c
true

julia> Ext(-43, Uint8[1])
ERROR: MsgPack Ext typecode -128 through -1 reserved by implementation
in call at /Users/sean/.julia/v0.4/MsgPack/src/MsgPack.jl:48

julia> Ext(500, [0x65, 0x00])
ERROR: MsgPack Ext typecode must be in the range [-128, 127]
in call at /Users/sean/.julia/v0.4/MsgPack/src/MsgPack.jl:50

julia> Ext(-500, [0x65, 0x00])
ERROR: MsgPack Ext typecode must be in the range [-128, 127]
in call at /Users/sean/.julia/v0.4/MsgPack/src/MsgPack.jl:50
```