     @inlinable
     public func encode(to encoder: Encoder) throws {
         
-        switch self.type {
+        switch self.base {
         case .null:
             
             var container = encoder.singleValueContainer()
             try container.encodeNil()
             
-        case .boolean:
+        case let .boolean(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.boolValue!)
-            
-        case .string:
+            try container.encode(value)
+            
+        case let .string(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.string!)
-            
-        case .signed:
+            try container.encode(value)
+            
+        case let .signed(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.int64Value!)
-            
-        case .unsigned:
+            try container.encode(value)
+            
+        case let .unsigned(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.uint64Value!)
-            
-        case .number:
+            try container.encode(value)
+            
+        case let .number(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.doubleValue!)
-            
-        case .binary:
+            try container.encode(value)
+            
+        case let .binary(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.binary!)
-            
-        case .uuid:
+            try container.encode(value)
+            
+        case let .uuid(value):
             
             var container = encoder.singleValueContainer()
-            try container.encode(self.uuid!)
-            
-        case .array:
+            try container.encode(value)
+            
+        case let .array(value):
             
             var container = encoder.unkeyedContainer()
-            try container.encode(contentsOf: self.array!)
-            
-        case .dictionary:
+            try container.encode(contentsOf: value)
+            
+        case let .undecoded_array(value):
+            
+            var container = encoder.unkeyedContainer()
+            try container.encode(contentsOf: value)
+            
+        case let .dictionary(value):
             
             var container = encoder.container(keyedBy: CodingKey.self)
             
-            for (key, value) in self.dictionary! {
+            for (key, value) in value {
                 try container.encode(value, forKey: CodingKey(stringValue: key))
             }
-            
-        default:
-            
-            var container = encoder.singleValueContainer()
-            try container.encodeNil()
-        }
-    }
-}
+        }
+    }
+}

    
    @frozen
    @usableFromInline
    struct UndecodedObject {
        
        @usableFromInline
        let type: DataPackType
        
        @usableFromInline
        let data: Data
        
        @inlinable
        init(data: Data) {
            if let type = data.first {
                switch type {
                case 0x3F: self.type = .null
                case 0x66, 0x74: self.type = .boolean
                case 0x69: self.type = .signed
                case 0x75: self.type = .unsigned
                case 0x6E: self.type = .number
                case 0x73: self.type = .string
                case 0x62: self.type = .binary
                case 0x67: self.type = .uuid
                case 0x61: self.type = .array
                case 0x64: self.type = .dictionary
                default: self.type = .unknown(type)
                }
            } else {
                self.type = .null
            }
            self.data = type == .boolean ? data : data.dropFirst()
        }
    }
}

extension DataPack.UndecodedObject {
    
    @inlinable
    var boolValue: Bool? {
        guard let value = data.first else { return nil }
        switch value {
        case 0x66: return false
        case 0x74: return true
        default: return nil
        }
    }
    
    @inlinable
    var int64Value: Int64? {
        guard type == .signed else { return nil }
        switch data.count {
        case 1: return Int64(data.load(as: Int8.self))
        case 2: return Int64(Int16(bigEndian: data.load(as: Int16.self)))
        case 4: return Int64(Int32(bigEndian: data.load(as: Int32.self)))
        case 8: return Int64(bigEndian: data.load(as: Int64.self))
        default: return nil
        }
    }
    
    @inlinable
    var uint64Value: UInt64? {
        guard type == .unsigned else { return nil }
        switch data.count {
        case 1: return UInt64(data.load(as: UInt8.self))
        case 2: return UInt64(UInt16(bigEndian: data.load(as: UInt16.self)))
        case 4: return UInt64(UInt32(bigEndian: data.load(as: UInt32.self)))
        case 8: return UInt64(bigEndian: data.load(as: UInt64.self))
        default: return nil
        }
    }
    
    @inlinable
    var doubleValue: Double? {
        guard data.count == 8 && type == .number else { return nil }
        return Double(bitPattern: UInt64(bigEndian: data.load(as: UInt64.self)))
    }
    
    @inlinable
    var string: String? {
        guard type == .string else { return nil }
        return String(bytes: data, encoding: .utf8)
    }
    
    @inlinable
    var binary: Data? {
        switch type {
        case .binary: return data
        case .unknown: return data
        default: return nil
        }
    }
    
    @inlinable
    var uuid: UUID? {
        guard data.count == 16 && type == .uuid else { return nil }
        return UUID(uuid: data.load(as: uuid_t.self))
    }
    
    @inlinable
    var array: [DataPack]? {
        guard type == .array else { return nil }
        return (0..<count).map { self[$0] }
    }
    
    @inlinable
    var dictionary: [String: DataPack]? {
        guard type == .dictionary else { return nil }
        return Dictionary((0..<count).lazy.compactMap { self[keyValuePairs: $0] }) { lhs, _ in lhs }
    }
}

extension DataPack.UndecodedObject {
    
    @inlinable
    var count: Int {
        guard data.count >= 8 && (type == .array || type == .dictionary) else { return 0 }
        return Int(UInt64(bigEndian: data.prefix(8).load(as: UInt64.self)))
    }
    
    @inlinable
    subscript(index: Int) -> DataPack {
        
        guard type == .array else { return nil }
        
        let count = self.count
        let table_size = (count + 1) << 3

    case uuid
    case array
    case dictionary
}

@frozen
public struct DataPack {
    
    @usableFromInline
    enum Base {
