├── .docs ├── css │ └── site.css ├── documentation │ └── twitterapachethrift │ │ ├── index.html │ │ ├── preencodedcontainer │ │ ├── !=(_:_:).html │ │ ├── decodable-implementations.html │ │ ├── encodable-implementations.html │ │ ├── encode(to:).html │ │ ├── encodeddata(_:).html │ │ ├── equatable-implementations.html │ │ ├── index.html │ │ ├── init(from:).html │ │ ├── init(fromthrift:)-41zsf.html │ │ ├── init(fromthrift:)-77io6.html │ │ ├── thriftdecodable-implementations.html │ │ ├── thriftencodable-implementations.html │ │ ├── thriftencode(to:).html │ │ ├── thrifttype()-5iqpe.html │ │ ├── thrifttype()-8jmnu.html │ │ ├── validate().html │ │ └── value(_:).html │ │ ├── thriftcodable.html │ │ ├── thriftdecodable │ │ ├── index.html │ │ ├── init(fromthrift:)-1gwt3.html │ │ └── init(fromthrift:)-xmzy.html │ │ ├── thriftdecoder │ │ ├── codingpath.html │ │ ├── container(keyedby:).html │ │ ├── decode(_:from:).html │ │ ├── index.html │ │ ├── init().html │ │ ├── singlevaluecontainer().html │ │ ├── specification.html │ │ ├── unkeyedcontainer().html │ │ └── userinfo.html │ │ ├── thriftdecodererror │ │ ├── codingkeymissingintvalue(key:).html │ │ ├── error-implementations.html │ │ ├── index.html │ │ ├── keyordermismatch.html │ │ ├── localizeddescription.html │ │ ├── nonutf8stringdata(_:).html │ │ ├── readbufferoverflow.html │ │ ├── undecodabletype(type:).html │ │ ├── unexpectedlyfoundnil.html │ │ ├── uninitializeddecodingdata.html │ │ └── unsupportedthrifttype.html │ │ ├── thriftencodable │ │ ├── index.html │ │ ├── thriftencode(to:)-13pj0.html │ │ ├── thriftencode(to:)-7sdty.html │ │ ├── thrifttype()-4a5kx.html │ │ ├── thrifttype()-80586.html │ │ ├── validate()-8rn04.html │ │ └── validate()-9e3nl.html │ │ ├── thriftencoder │ │ ├── codingpath.html │ │ ├── container(keyedby:).html │ │ ├── encode(_:).html │ │ ├── index.html │ │ ├── init().html │ │ ├── singlevaluecontainer().html │ │ ├── specification.html │ │ ├── unkeyedcontainer().html │ │ └── userinfo.html │ │ ├── thriftencodererror │ │ ├── codingkeymissingintvalue(key:).html │ │ ├── error-implementations.html │ │ ├── index.html │ │ ├── localizeddescription.html │ │ ├── unencodabletype(type:).html │ │ ├── uninitializedencodingdata.html │ │ └── validationfailure(type:).html │ │ ├── thriftspecification │ │ ├── !=(_:_:).html │ │ ├── compact.html │ │ ├── equatable-implementations.html │ │ ├── index.html │ │ └── standard.html │ │ └── thrifttype │ │ ├── !=(_:_:).html │ │ ├── bool.html │ │ ├── byte.html │ │ ├── double.html │ │ ├── equatable-implementations.html │ │ ├── hash(into:).html │ │ ├── hashvalue.html │ │ ├── index.html │ │ ├── int16.html │ │ ├── int32.html │ │ ├── int64.html │ │ ├── list.html │ │ ├── map.html │ │ ├── rawrepresentable-implementations.html │ │ ├── set.html │ │ ├── stop.html │ │ ├── string.html │ │ ├── structure.html │ │ └── void.html ├── favicon.ico ├── favicon.svg └── img │ ├── added-icon.svg │ ├── deprecated-icon.svg │ └── modified-icon.svg ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yml │ └── test.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── PROJECT ├── Package.swift ├── README.md ├── Scripts └── build_docs.sh ├── Sources └── TwitterApacheThrift │ ├── Int+Compression.swift │ ├── MemoryBuffer.swift │ ├── MutableThriftBinary.swift │ ├── MutableThriftCompactBinary.swift │ ├── PreencodedContainer.swift │ ├── ThriftBinary.swift │ ├── ThriftCodable.swift │ ├── ThriftCompactBinary.swift │ ├── ThriftDecoder.swift │ ├── ThriftEncoder.swift │ ├── ThriftObject.swift │ ├── ThriftSpecification.swift │ ├── ThriftType.swift │ └── TwitterApacheThrift.docc │ ├── TwitterApacheThrift.md │ └── thrift_overview.md ├── Tests └── TwitterApacheThriftTests │ ├── AutoGenerated │ ├── CollectiontThriftStruct.swift │ ├── EnumStruct.swift │ ├── FoundationThriftStruct.swift │ ├── MyUnion.swift │ ├── OptionalThriftStruct.swift │ ├── SomeEnum.swift │ ├── SubobjectThriftStruct.swift │ ├── UnionClassA.swift │ ├── UnionClassB.swift │ └── UnionStruct.swift │ ├── Fixture.thrift │ ├── Fixtures.swift │ ├── MutableThriftBinaryTests.swift │ ├── MutableThriftCompactBinaryTests.swift │ ├── PreencodedContainerTests.swift │ ├── ThriftBinaryTests.swift │ ├── ThriftCompactBinaryTests.swift │ ├── ThriftCompactDecoderTests.swift │ ├── ThriftCompactEncoderTests.swift │ ├── ThriftDecodingTests.swift │ └── ThriftEncoderTests.swift └── makefile /.docs/documentation/twitterapachethrift/preencodedcontainer/!=(_:_:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | !=(_:_:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Operator 68 |

!=(_:_:)

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Equatable.!=(_:_:). 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
static func != (lhs: Self, rhs: Self) -> Bool
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/preencodedcontainer/encode(to:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | encode(to:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Instance Method 68 |

encode(to:)

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Encodable.encode(to:). 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
func encode(to encoder: Encoder) throws
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/preencodedcontainer/encodeddata(_:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | PreencodedContainer.encodedData(_:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

PreencodedContainer.encodedData(_:)

62 |
63 | 64 |
65 |
66 |
67 | Preencoded data 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case encodedData(Data)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/preencodedcontainer/init(from:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | init(from:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Initializer 68 |

init(from:)

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Decodable.init(from:). 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
init(from decoder: Decoder) throws
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/preencodedcontainer/value(_:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | PreencodedContainer.value(_:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

PreencodedContainer.value(_:)

62 |
63 | 64 |
65 |
66 |
67 | A value that needs to be encoded/decoded 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case value(T)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftcodable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftCodable| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 50 | 51 |
52 |
53 | Type Alias 54 |

ThriftCodable

55 |
56 | 57 |
58 |
59 |
60 | A convenient shortcut for indicating something is both encodable and decodable. 61 |
62 |
63 | 64 | 65 | 66 |
67 |
68 |

Declaration

69 |
70 |
typealias ThriftCodable = ThriftDecodable & ThriftEncodable
71 |
72 |
73 | 74 |
75 |
76 | 77 | 78 | 79 | 80 |
81 | 82 |
83 |
84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/codingpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | codingPath| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Property 61 |

codingPath

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Decoder.codingPath. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
var codingPath: [CodingKey]
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/container(keyedby:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | container(keyedBy:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

container(keyedBy:)

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Decoder.container(keyedBy:). 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> where Key : CodingKey
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/init().html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | init()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Initializer 61 |

init()

62 |
63 | 64 |
65 |
66 |
67 | Initializes self with defaults. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
init()
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/singlevaluecontainer().html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | singleValueContainer()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

singleValueContainer()

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Decoder.singleValueContainer(). 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func singleValueContainer() throws -> SingleValueDecodingContainer
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/specification.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | specification| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Property 61 |

specification

62 |
63 | 64 |
65 |
66 |
67 | The specification to be used for decoding 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
var specification: ThriftSpecification
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/unkeyedcontainer().html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | unkeyedContainer()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

unkeyedContainer()

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Decoder.unkeyedContainer(). 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func unkeyedContainer() throws -> UnkeyedDecodingContainer
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecoder/userinfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | userInfo| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Property 61 |

userInfo

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Decoder.userInfo. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
var userInfo: [CodingUserInfoKey : Any]
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/codingkeymissingintvalue(key:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.codingKeyMissingIntValue(key:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.codingKeyMissingIntValue(key:)

62 |
63 | 64 |
65 |
66 |
67 | CodingKey is missing the value 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case codingKeyMissingIntValue(key: CodingKey)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/keyordermismatch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.keyOrderMismatch| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.keyOrderMismatch

62 |
63 | 64 |
65 |
66 |
67 | The key of the field is not the next key in the thrift, possibly because of malformed thrift data or model discrepancy 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case keyOrderMismatch
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/localizeddescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | localizedDescription| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Instance Property 68 |

localizedDescription

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Error.localizedDescription. 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
var localizedDescription: String { get }
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/nonutf8stringdata(_:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.nonUTF8StringData(_:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.nonUTF8StringData(_:)

62 |
63 | 64 |
65 |
66 |
67 | The string found while decoding is not UTF8 formatted, possibly because of malformed thrift or an encoding error. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case nonUTF8StringData(Data)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/readbufferoverflow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.readBufferOverflow| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.readBufferOverflow

62 |
63 | 64 |
65 |
66 |
67 | The buffer overflowed while trying to read a field, possibly because of using the wrong model type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case readBufferOverflow
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/undecodabletype(type:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.undecodableType(type:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.undecodableType(type:)

62 |
63 | 64 |
65 |
66 |
67 | The type is not encodable, example not conforming to ThriftDecodable 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case undecodableType(type: Any)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/unexpectedlyfoundnil.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.unexpectedlyFoundNil| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.unexpectedlyFoundNil

62 |
63 | 64 |
65 |
66 |
67 | The decoder unexpectedly found nil while decoding 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case unexpectedlyFoundNil
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/uninitializeddecodingdata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.uninitializedDecodingData| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.uninitializedDecodingData

62 |
63 | 64 |
65 |
66 |
67 | Internal buffer is uninitialized should only happen if using methods other then decode<T>(_ type: T.Type, from data: Data) for decoding 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case uninitializedDecodingData
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftdecodererror/unsupportedthrifttype.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftDecoderError.unsupportedThriftType| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftDecoderError.unsupportedThriftType

62 |
63 | 64 |
65 |
66 |
67 | The thrift data has a unsupported type value 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case unsupportedThriftType
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodable/thrifttype()-4a5kx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | thriftType()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Type Method 61 |

thriftType()

62 |
63 | 64 |
65 |
66 |
67 | Provides an override point to all the protocol implementer to provide a different ThriftType such as for wrapping 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
static func thriftType() throws -> ThriftType
78 |
79 |
80 |

Return Value

The thrift type of the implementer

Discussion

81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodable/validate()-8rn04.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | validate()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

validate()

62 |
63 | 64 |
65 |
66 |
67 | Provides a validation step before encoding to insure fields are set to appropriate values provided by the implementer. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func validate() throws
78 |
79 |
80 |

Discussion

81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/codingpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | codingPath| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Property 61 |

codingPath

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Encoder.codingPath. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
var codingPath: [CodingKey]
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/container(keyedby:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | container(keyedBy:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

container(keyedBy:)

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Encoder.container(keyedBy:). 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key : CodingKey
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/init().html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | init()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Initializer 61 |

init()

62 |
63 | 64 |
65 |
66 |
67 | Initializes self with defaults. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
init()
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/singlevaluecontainer().html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | singleValueContainer()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

singleValueContainer()

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Encoder.singleValueContainer(). 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func singleValueContainer() -> SingleValueEncodingContainer
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/specification.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | specification| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Property 61 |

specification

62 |
63 | 64 |
65 |
66 |
67 | The specification to be used for encoding 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
var specification: ThriftSpecification
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/unkeyedcontainer().html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | unkeyedContainer()| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Method 61 |

unkeyedContainer()

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Encoder.unkeyedContainer(). 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
func unkeyedContainer() -> UnkeyedEncodingContainer
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencoder/userinfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | userInfo| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Instance Property 61 |

userInfo

62 |
63 | 64 |
65 |
66 |
67 | Inherited from Encoder.userInfo. 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
var userInfo: [CodingUserInfoKey : Any]
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodererror/codingkeymissingintvalue(key:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftEncoderError.codingKeyMissingIntValue(key:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftEncoderError.codingKeyMissingIntValue(key:)

62 |
63 | 64 |
65 |
66 |
67 | CodingKey is missing the value 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case codingKeyMissingIntValue(key: CodingKey)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodererror/localizeddescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | localizedDescription| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Instance Property 68 |

localizedDescription

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Error.localizedDescription. 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
var localizedDescription: String { get }
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodererror/unencodabletype(type:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftEncoderError.unencodableType(type:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftEncoderError.unencodableType(type:)

62 |
63 | 64 |
65 |
66 |
67 | The type is not encodable, example not conforming to ThriftEncodable 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case unencodableType(type: Any)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodererror/uninitializedencodingdata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftEncoderError.uninitializedEncodingData| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftEncoderError.uninitializedEncodingData

62 |
63 | 64 |
65 |
66 |
67 | Internal buffer is uninitialized 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case uninitializedEncodingData
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftencodererror/validationfailure(type:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftEncoderError.validationFailure(type:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftEncoderError.validationFailure(type:)

62 |
63 | 64 |
65 |
66 |
67 | The validate method returned an error 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case validationFailure(type: Any)
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftspecification/!=(_:_:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | !=(_:_:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Operator 68 |

!=(_:_:)

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Equatable.!=(_:_:). 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
static func != (lhs: Self, rhs: Self) -> Bool
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftspecification/compact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftSpecification.compact| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftSpecification.compact

62 |
63 | 64 |
65 |
66 |
67 | The compact specification https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case compact
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thriftspecification/standard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftSpecification.standard| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftSpecification.standard

62 |
63 | 64 |
65 |
66 |
67 | The standard specification https://thrift.apache.org/static/files/thrift-20070401.pdf 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case standard
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/!=(_:_:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | !=(_:_:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Operator 68 |

!=(_:_:)

69 |
70 | 71 |
72 |
73 |
74 | Inherited from Equatable.!=(_:_:). 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
static func != (lhs: Self, rhs: Self) -> Bool
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/bool.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.bool| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.bool

62 |
63 | 64 |
65 |
66 |
67 | A bool type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case bool
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/byte.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.byte| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.byte

62 |
63 | 64 |
65 |
66 |
67 | Represented as a UInt8 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case byte
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/double.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.double| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.double

62 |
63 | 64 |
65 |
66 |
67 | A Double type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case double
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/hash(into:).html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | hash(into:)| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Instance Method 68 |

hash(into:)

69 |
70 | 71 |
72 |
73 |
74 | Inherited from RawRepresentable.hash(into:). 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
func hash(into hasher: inout Hasher)
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/hashvalue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | hashValue| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 64 | 65 |
66 |
67 | Instance Property 68 |

hashValue

69 |
70 | 71 |
72 |
73 |
74 | Inherited from RawRepresentable.hashValue. 75 |
76 |
77 | 78 | 79 | 80 |
81 |
82 |

Declaration

83 |
84 |
var hashValue: Int { get }
85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/int16.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.int16| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.int16

62 |
63 | 64 |
65 |
66 |
67 | A Int16 type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case int16
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/int32.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.int32| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.int32

62 |
63 | 64 |
65 |
66 |
67 | A Int32 type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case int32
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/int64.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.int64| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.int64

62 |
63 | 64 |
65 |
66 |
67 | A Int64 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case int64
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.list| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.list

62 |
63 | 64 |
65 |
66 |
67 | Represented as an array 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case list
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/map.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.map| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.map

62 |
63 | 64 |
65 |
66 |
67 | Represented as a dictionary 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case map
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.set| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.set

62 |
63 | 64 |
65 |
66 |
67 | A Set type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case set
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/stop.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.stop| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.stop

62 |
63 | 64 |
65 |
66 |
67 | Thrift control type not mapped to swift type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case stop
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/string.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.string| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.string

62 |
63 | 64 |
65 |
66 |
67 | This type can be either a String or Data it is determined based on the type in the model 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case string
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/structure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.structure| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.structure

62 |
63 | 64 |
65 |
66 |
67 | A struct or a class depending on the model 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case structure
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/documentation/twitterapachethrift/thrifttype/void.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ThriftType.void| Documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 57 | 58 |
59 |
60 | Case 61 |

ThriftType.void

62 |
63 | 64 |
65 |
66 |
67 | Thrift control type not mapped to swift type 68 |
69 |
70 | 71 | 72 | 73 |
74 |
75 |

Declaration

76 |
77 |
case void
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
88 | 89 |
90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /.docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twitter/ios-twitter-apache-thrift/9446faa2f1eb0232fdae11771563322b4d868364/.docs/favicon.ico -------------------------------------------------------------------------------- /.docs/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.docs/img/added-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.docs/img/deprecated-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.docs/img/modified-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | One line summary of the issue here. 2 | 3 | ### Expected behavior 4 | 5 | As concisely as possible, describe the expected behavior. 6 | 7 | ### Actual behavior 8 | 9 | As concisely as possible, describe the observed behavior. 10 | 11 | ### Steps to reproduce the behavior 12 | 13 | Please list all relevant steps to reproduce the observed behavior. 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Problem 2 | 3 | Explain the context and why you're making that change. What is the 4 | problem you're trying to solve? In some cases there is not a problem 5 | and this can be thought of being the motivation for your change. 6 | 7 | # Solution 8 | 9 | Describe the modifications you've done. 10 | 11 | # Result 12 | 13 | What will change as a result of your pull request? Note that sometimes 14 | this section is unnecessary because it is self-explanatory based on 15 | the solution. 16 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | name: Build 6 | jobs: 7 | test-macOS: 8 | runs-on: macOS-latest 9 | steps: 10 | - uses: actions/checkout@main 11 | - name: SwiftPM Build 12 | run: swift test 13 | test-iOS: 14 | runs-on: macOS-latest 15 | steps: 16 | - uses: actions/checkout@main 17 | - name: xcodebuild 18 | run: |- 19 | xcodebuild \ 20 | -scheme "TwitterApacheThrift" \ 21 | -destination "platform=iOS Simulator,OS=latest,name=iPhone 11 Pro Max" \ 22 | -quiet \ 23 | build test 24 | test-linux: 25 | runs-on: ubuntu-latest 26 | container: 27 | image: swift:5.5.0 28 | steps: 29 | - uses: actions/checkout@main 30 | - name: SwiftPM Build 31 | run: swift test 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | on: pull_request 2 | name: Test 3 | jobs: 4 | test-macOS: 5 | runs-on: macOS-latest 6 | steps: 7 | - uses: actions/checkout@main 8 | - name: SwiftPM Build 9 | run: swift test 10 | test-iOS: 11 | runs-on: macOS-latest 12 | steps: 13 | - uses: actions/checkout@main 14 | - name: xcodebuild 15 | run: |- 16 | xcodebuild \ 17 | -scheme "TwitterApacheThrift" \ 18 | -destination "platform=iOS Simulator,OS=latest,name=iPhone 11 Pro Max" \ 19 | -quiet \ 20 | build test 21 | test-linux: 22 | runs-on: ubuntu-latest 23 | container: 24 | image: swift:5.5 25 | steps: 26 | - uses: actions/checkout@main 27 | - name: SwiftPM Build 28 | run: swift test 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gcda 2 | *.gcno 3 | *.mode1v3 4 | *.pbxuser 5 | *.pyc 6 | *.xccheckout 7 | *.xcscmblueprint 8 | .DS_Store 9 | .build/ 10 | .buildstats/ 11 | /.bundle/ 12 | /.gems/ 13 | /.swiftpm 14 | /BuildConfiguration/Variables 15 | /DerivedData/ 16 | /InstrumentedBuild/ 17 | artifacts/ 18 | build/ 19 | buildResults/ 20 | Packages 21 | project.xcworkspace 22 | docs/_build/ 23 | docset-installed.txt 24 | lint_report/ 25 | reports/ 26 | testbuild.zip 27 | xcuserdata/ 28 | xcbaselines/ 29 | .docc-build/ 30 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Twitter Apache Thrift Change Log 2 | 3 | ## Info 4 | 5 | **Document version:** 1.1.0 6 | 7 | **Last updated:** 11/09/2021 8 | 9 | **Author:** Justin Anderson 10 | 11 | ## History 12 | 13 | ### 1.1.0 14 | 15 | - Added Compact Thrift Encoding and Decoding 16 | - Updated to Swift 5.5 17 | 18 | ### 1.0.1 19 | 20 | - Added Documentation 21 | 22 | ### 1.0.0 23 | 24 | - Initial release 25 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | We feel that a welcoming community is important and we ask that you follow Twitter's 2 | [Open Source Code of Conduct](https://github.com/twitter/code-of-conduct/blob/master/code-of-conduct.md) 3 | in all interactions with the community. 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to get patches from you! 4 | 5 | ## Getting Started 6 | 7 | We follow the [GitHub Flow Workflow](https://guides.github.com/introduction/flow/) 8 | 9 | 1. Fork the project 10 | 1. Check out the `main` branch 11 | 1. Create a feature branch 12 | 1. Write code and tests for your change 13 | 1. From your branch, make a pull request against `twitter/ios-twitter-apache-thrift/main` 14 | 1. Work with repo maintainers to get your change reviewed 15 | 1. Wait for your change to be pulled into `twitter/ios-twitter-apache-thrift/master` 16 | 1. Delete your feature branch 17 | 18 | # License 19 | 20 | By contributing your code, you agree to license your contribution under the 21 | terms of the APLv2: https://github.com/twitter/ios-twitter-apache-thrift/blob/master/LICENSE 22 | 23 | # Code of Conduct 24 | 25 | Read our [Code of Conduct](CODE_OF_CONDUCT.md) for the project. 26 | -------------------------------------------------------------------------------- /PROJECT: -------------------------------------------------------------------------------- 1 | owners: 2 | - thrift-ios:phab-ios:phab 3 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | // 4 | // Copyright 2020 Twitter, Inc. 5 | // Licensed under the Apache License, Version 2.0 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | import PackageDescription 9 | 10 | let package = Package( 11 | name: "TwitterApacheThrift", 12 | platforms: [ 13 | .iOS("13.4"), 14 | .macOS("10.15.4") 15 | ], 16 | products: [ 17 | .library( 18 | name: "TwitterApacheThrift", 19 | type: .static, 20 | targets: [ 21 | "TwitterApacheThrift" 22 | ] 23 | ) 24 | ], 25 | dependencies: [], 26 | targets: [ 27 | .target( 28 | name: "TwitterApacheThrift", 29 | dependencies: [] 30 | ), 31 | .testTarget( 32 | name: "TwitterApacheThriftTests", 33 | dependencies: [ 34 | "TwitterApacheThrift" 35 | ], 36 | exclude:[ 37 | "Fixture.thrift" 38 | ] 39 | ) 40 | ] 41 | ) 42 | -------------------------------------------------------------------------------- /Scripts/build_docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | xcodebuild docbuild -scheme TwitterApacheThrift -derivedDataPath ./.build/docs/TwitterApacheThrift -destination "platform=iOS Simulator,OS=13.5,name=iPhone 8" 4 | 5 | BUNDLE_PATH=$(find ./.build/docs/TwitterApacheThrift -type d -name '*.doccarchive') 6 | echo "$BUNDLE_PATH" 7 | 8 | cd docc2html || exit 2 9 | swift run docc2html --force ../"$BUNDLE_PATH" ../docs 10 | cd ../ || exit 2 11 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/Int+Compression.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // Int+Compression.swift 6 | // TwitterApacheThrift 7 | // 8 | // Created on 9/24/21. 9 | // Copyright © 2021 Twitter, Inc. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | 14 | extension Int16 { 15 | init(zigZag value: Int16) { 16 | self = Int16((value >> 1) ^ -(value & 1)) 17 | } 18 | } 19 | extension Int { 20 | var zigZag: Int { 21 | if self.bitWidth > 32 { 22 | return Int((Int64(self) << 1) ^ (Int64(self) >> 63)) 23 | } 24 | return (self << 1) ^ (self >> 31) 25 | } 26 | init(zigZag value: Int64) { 27 | self = Int((value >> 1) ^ -(value & 1)) 28 | } 29 | init(zigZag value: Int32) { 30 | self = Int((value >> 1) ^ -(value & 1)) 31 | } 32 | } 33 | 34 | extension Int32 { 35 | var zigZag: Int32 { 36 | return (self << 1) ^ (self >> 31) 37 | } 38 | init(zigZag value: Int32) { 39 | self = (value >> 1) ^ -(value & 1) 40 | } 41 | } 42 | 43 | extension Int64 { 44 | var zigZag: Int64 { 45 | return (self << 1) ^ (self >> 63) 46 | } 47 | init(zigZag value: UInt64) { 48 | self = Int64(value >> 1) ^ (-Int64(value & 1)) 49 | } 50 | } 51 | 52 | extension UInt64 { 53 | var zigZag: Int64 { 54 | return (Int64(self) << 1) ^ (Int64(self) >> 63) 55 | } 56 | init(zigZag value: Int64) { 57 | self = UInt64((value >> 1) ^ -(value & 1)) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/MemoryBuffer.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // MemoryBuffer.swift 6 | // TwitterApacheThrift 7 | // 8 | // Created on 3/26/20. 9 | // Copyright © 2020 Twitter. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | 14 | /// A class for reading a thrift data buffer. 15 | class MemoryBuffer { 16 | 17 | /// The thrift data buffer 18 | var buffer: Data 19 | 20 | /// The offset of read cursor 21 | private var offset: Int = 0 22 | 23 | /// Initializes the class with a thrift buffer 24 | /// - Parameter buffer: The thrift buffer 25 | init(buffer: Data) { 26 | self.buffer = buffer 27 | } 28 | 29 | /// Reads data from the buffer with the given length 30 | /// - Parameter size: The amount of data to read in bytes 31 | /// - Throws: Throws `ThriftDecoderError.readBufferOverflow` if the size is greater then the amount of data remaining 32 | /// - Returns: The data from the buffer 33 | /// - Note: Calling this method will return new data from the buffer each call 34 | func read(size: Int) throws -> Data { 35 | if buffer.count - offset < size || offset < 0 { 36 | throw ThriftDecoderError.readBufferOverflow 37 | } 38 | let data = buffer.subdata(in: offset.. Data { 61 | return buffer 62 | } 63 | 64 | /// Appends bytes to the end of the buffer 65 | /// - Parameter bytes: The bytes to append 66 | func write(bytes: [UInt8]) { 67 | buffer.append(contentsOf: bytes) 68 | } 69 | 70 | /// Appends data to the end of the buffer 71 | /// - Parameter data: The data to append 72 | func write(data: Data) { 73 | buffer.append(data) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/MutableThriftCompactBinary.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0// 4 | // 5 | // MutableThriftCompactBinary.swift 6 | // TwitterApacheThrift 7 | // 8 | // Created on 9/24/21. 9 | // Copyright © 2021 Twitter. All rights reserved. 10 | 11 | import CoreFoundation 12 | import Foundation 13 | 14 | class MutableThriftCompactBinary: MutableThriftBinary { 15 | override func write(_ value: Int16) { 16 | write(Int32(value)) 17 | } 18 | 19 | override func write(_ value: Int32) { 20 | let bytes = encodedUnsignedLEB(value: value.zigZag) 21 | insert(data: bytes) 22 | } 23 | 24 | override func write(_ value: Int64) { 25 | let bytes = encodedUnsignedLEB(value: value.zigZag) 26 | insert(data: bytes) 27 | } 28 | 29 | override func write(_ value: Double) { 30 | var bits = CFSwapInt64HostToLittle(value.bitPattern) 31 | let buffer = withUnsafePointer(to: &bits) { 32 | return Data(bytes: UnsafePointer(OpaquePointer($0)), count: MemoryLayout.size) 33 | } 34 | insert(data: buffer) 35 | } 36 | 37 | override func write(_ data: Data) { 38 | let lengthBytes = encodedUnsignedLEB(value: Int32(data.count)) 39 | insert(data: lengthBytes) 40 | insert(data: data) 41 | } 42 | 43 | override func writeFieldBegin(fieldType: ThriftType, fieldID: Int, previousId: Int) { 44 | // check if we can use delta encoding for the field id 45 | let diff = fieldID - previousId 46 | if (fieldID > previousId) && (diff <= 15) { 47 | // Write them together 48 | write((UInt8(fieldID - previousId) << 4) | fieldType.compactValue) 49 | 50 | } else { 51 | // Write them separate 52 | write(fieldType.compactValue) 53 | super.write(Int16(fieldID.zigZag)) 54 | } 55 | } 56 | 57 | override func writeListMetadata(elementType: ThriftType, count: Int) { 58 | if count < 15 { 59 | write((UInt8(count) << 4) | elementType.compactValue) 60 | } else { 61 | write(0xF0 | elementType.compactValue) 62 | insert(data: encodedUnsignedLEB(value: count)) 63 | } 64 | } 65 | 66 | override func writeMapMetadata(keyType: ThriftType, valueType: ThriftType, count: Int) { 67 | if count == 0 { 68 | write(UInt8(0)) 69 | return 70 | } 71 | insert(data: encodedUnsignedLEB(value: count)) 72 | write((keyType.compactValue << 4) | valueType.compactValue) 73 | } 74 | 75 | func encodedUnsignedLEB(value: T) -> Data { 76 | var value = value 77 | var count = 0 78 | var data = Data() 79 | data.reserveCapacity(10) 80 | repeat { 81 | var byte = UInt8(value & 0x7F) 82 | value = value >> 7 83 | if value != 0 { 84 | byte |= 0x80 85 | } 86 | data.append(byte) 87 | count += 1 88 | } while value != 0 89 | 90 | return data 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/PreencodedContainer.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // PreencodedContainer.swift 6 | // TwitterApacheThrift 7 | // 8 | // Created on 7/1/20. 9 | // Copyright © 2020 Twitter. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | 14 | /// A container allowing pre-encoded data to be placed in the encoding 15 | /// buffer instead of a value 16 | /// 17 | /// For example the first struct would take .encodedData([0, 57]) and 18 | /// this would allow the second struct to be decoded with a value of 57 19 | /// 20 | /// struct SomeStruct: ThriftCodable { 21 | /// let value: PreencodedContainer 22 | /// } 23 | /// 24 | /// struct AnotherStruct: ThriftCodable { 25 | /// let value: Int16 26 | /// } 27 | /// 28 | public enum PreencodedContainer { 29 | /// Preencoded data 30 | case encodedData(Data) 31 | /// A value that needs to be encoded/decoded 32 | case value(T) 33 | } 34 | 35 | extension PreencodedContainer: Equatable where T: Equatable {} 36 | extension PreencodedContainer: Hashable where T: Hashable {} 37 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/ThriftCodable.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | /// A convenient shortcut for indicating something is both encodable and decodable. 6 | public typealias ThriftCodable = ThriftDecodable & ThriftEncodable 7 | 8 | /// A protocol for types which can be encoded from thrift. 9 | public protocol ThriftEncodable: Encodable { 10 | /// Encodes this value into the given thrift encoder. 11 | /// 12 | /// If the value fails to encode anything, `encoder` will encode an empty 13 | /// keyed container in its place. 14 | /// 15 | /// This function throws an error if any values are invalid for the given 16 | /// encoder's format. 17 | /// 18 | /// - Note: This function is not required to be implemented, 19 | /// however `func encode(to encoder: Encoder) throws` is required. It 20 | /// should be automatically created by the compiler. 21 | /// 22 | /// - Parameter encoder: The encoder to write data to. 23 | func thriftEncode(to encoder: ThriftEncoder) throws 24 | 25 | /// Provides an override point to all the protocol implementer to provide 26 | /// a different ThriftType such as for wrapping 27 | /// 28 | /// - Note: This function is not required to be implemented, defaults to struct 29 | /// 30 | /// - returns: The thrift type of the implementer 31 | static func thriftType() throws -> ThriftType 32 | 33 | /// Provides a validation step before encoding to insure fields are set 34 | /// to appropriate values provided by the implementer. 35 | /// 36 | /// - Note: This function is not required to be implemented, default is no validation 37 | /// 38 | /// - throws: `ThriftEncoderError.validationFailure()` if field validation fails 39 | func validate() throws 40 | } 41 | 42 | /// A protocol for types which can be decoded from thrift. 43 | public protocol ThriftDecodable: Decodable { 44 | 45 | /// Creates a new instance by decoding from the given thrift decoder. 46 | /// 47 | /// This initializer throws an error if reading from the decoder fails, or 48 | /// if the data read is corrupted or otherwise invalid. 49 | /// 50 | /// - Note: This function is not required to be implemented, 51 | /// however `init(from decoder: Decoder)` is required. It should be automatically 52 | /// created by the compiler. 53 | /// 54 | /// - Parameter decoder: The decoder to read data from. 55 | init(fromThrift decoder: ThriftDecoder) throws 56 | } 57 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/ThriftObject.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // ThriftObject.swift 6 | // TwitterApacheThrift 7 | // 8 | // Created on 9/24/21. 9 | // Copyright © 2021 Twitter, Inc. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | 14 | indirect enum ThriftObject: Hashable { 15 | case data(Data) 16 | case unkeyedCollection(ThriftUnkeyedCollection) 17 | case keyedCollection(ThriftKeyedCollection) 18 | case `struct`(ThriftStruct) 19 | case stop 20 | } 21 | 22 | struct ThriftValue: Hashable { 23 | var index: Int? 24 | var type: ThriftType 25 | var data: ThriftObject 26 | } 27 | 28 | struct ThriftStruct: Hashable { 29 | var index: Int? 30 | var fields: [Int: ThriftValue] 31 | } 32 | 33 | struct ThriftUnkeyedCollection: Hashable { 34 | var index: Int? 35 | var count: Int 36 | var elementType: ThriftType 37 | var value: [ThriftObject] 38 | } 39 | 40 | struct ThriftKeyedCollection: Hashable { 41 | var index: Int? 42 | var count: Int 43 | var keyType: ThriftType 44 | var elementType: ThriftType 45 | var value: [Value] 46 | 47 | struct Value: Hashable { 48 | let key: ThriftObject 49 | let value: ThriftObject 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/ThriftSpecification.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // ThriftSpecification.swift 6 | // TwitterApacheThrift 7 | // 8 | // Created on 9/30/21. 9 | // Copyright © 2021 Twitter, Inc. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | 14 | /// The specification to be used for encoding and decoding 15 | public enum ThriftSpecification { 16 | /// The standard specification 17 | /// https://thrift.apache.org/static/files/thrift-20070401.pdf 18 | case standard 19 | /// The compact specification 20 | /// https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md 21 | case compact 22 | } 23 | -------------------------------------------------------------------------------- /Sources/TwitterApacheThrift/TwitterApacheThrift.docc/TwitterApacheThrift.md: -------------------------------------------------------------------------------- 1 | # ``TwitterApacheThrift`` 2 | 3 | Twitter Apache Thrift is a standalone, light-weight, data encoding library built for iOS, macOS, and Linux using Swift Codable. This is the encoding library we use in our clients for Apple platforms to communicate with the Twitter backend for specific endpoints. 4 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/CollectiontThriftStruct.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct CollectiontThriftStruct: ThriftCodable, Equatable { 11 | let arrays: [Double]? 12 | let maps: [String:String]? 13 | let sets: Set? 14 | 15 | enum CodingKeys: Int, CodingKey { 16 | case arrays = 1 17 | case maps = 2 18 | case sets = 3 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/EnumStruct.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct EnumStruct: ThriftCodable, Equatable { 11 | let enumValue: SomeEnum 12 | 13 | enum CodingKeys: Int, CodingKey { 14 | case enumValue = 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/FoundationThriftStruct.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct FoundationThriftStruct: ThriftCodable, Equatable { 11 | let boolValue: Bool 12 | let doubleValue: Double 13 | let int16Value: Int16 14 | let int32Value: Int32 15 | let int64Value: Int64 16 | let stringValue: String 17 | 18 | enum CodingKeys: Int, CodingKey { 19 | case boolValue = 1 20 | case doubleValue = 2 21 | case int16Value = 3 22 | case int32Value = 4 23 | case int64Value = 5 24 | case stringValue = 6 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/MyUnion.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public enum MyUnion: ThriftCodable, Equatable { 11 | 12 | case unionClassA(UnionClassA) 13 | case unionClassB(UnionClassB) 14 | 15 | enum CodingKeys: Int, CodingKey { 16 | case unionClassA = 1 17 | case unionClassB = 2 18 | } 19 | 20 | public init(from decoder: Decoder) throws { 21 | let container = try decoder.container(keyedBy: CodingKeys.self) 22 | if let decodedClass = try container.decodeIfPresent(UnionClassA.self, forKey: .unionClassA) { 23 | self = .unionClassA(decodedClass) 24 | } else if let decodedClass = try container.decodeIfPresent(UnionClassB.self, forKey: .unionClassB) { 25 | self = .unionClassB(decodedClass) 26 | } else { 27 | throw DecodingError.valueNotFound(MyUnion.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "MyUnion not decodable")) 28 | } 29 | } 30 | 31 | public func encode(to encoder: Encoder) throws { 32 | var container = encoder.container(keyedBy: CodingKeys.self) 33 | switch self { 34 | case .unionClassA(let codedClass): 35 | try container.encode(codedClass, forKey: .unionClassA) 36 | case .unionClassB(let codedClass): 37 | try container.encode(codedClass, forKey: .unionClassB) 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/OptionalThriftStruct.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct OptionalThriftStruct: ThriftCodable, Equatable { 11 | let int16Value: Int16? 12 | let someBool: Bool 13 | enum CodingKeys: Int, CodingKey { 14 | case int16Value = 1 15 | case someBool = 2 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/SomeEnum.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public enum SomeEnum: Int32, ThriftCodable, Equatable { 11 | case AAA = 1 12 | case BBB = 2 13 | 14 | public func thriftEncode(to encoder: ThriftEncoder) throws { 15 | var container = encoder.unkeyedContainer() 16 | try container.encode(self.rawValue) 17 | } 18 | 19 | public init(fromThrift decoder: ThriftDecoder) throws { 20 | var container = try decoder.unkeyedContainer() 21 | let value = try container.decode(Int32.self) 22 | guard let enumValue = SomeEnum(rawValue: value) else { 23 | throw ThriftDecoderError.undecodableType(type: value.self) 24 | } 25 | self = enumValue 26 | } 27 | 28 | public static func thriftType() -> ThriftType { 29 | return .int32 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/SubobjectThriftStruct.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct SubobjectThriftStruct: ThriftCodable, Equatable { 11 | let value: OptionalThriftStruct? 12 | let intValue: Int16 13 | 14 | enum CodingKeys: Int, CodingKey { 15 | case value = 1 16 | case intValue = 2 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/UnionClassA.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct UnionClassA: ThriftCodable, Equatable { 11 | let someString: String 12 | 13 | enum CodingKeys: Int, CodingKey { 14 | case someString = 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/UnionClassB.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct UnionClassB: ThriftCodable, Equatable { 11 | let someInt: Int64 12 | 13 | enum CodingKeys: Int, CodingKey { 14 | case someInt = 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/AutoGenerated/UnionStruct.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Scrooge 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | 7 | import Foundation 8 | import TwitterApacheThrift 9 | 10 | public struct UnionStruct: ThriftCodable, Equatable { 11 | let someUnion: MyUnion 12 | 13 | enum CodingKeys: Int, CodingKey { 14 | case someUnion = 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/Fixture.thrift: -------------------------------------------------------------------------------- 1 | namespace java com.twitter.thrift.encoding 2 | #@namespace scala com.twitter.thrift.encoding.thriftscala 3 | namespace swift ThriftEncoding 4 | 5 | struct FoundationThriftStruct { 6 | 1: required bool boolValue 7 | 2: required double doubleValue 8 | 3: required i16 int16Value 9 | 4: required i32 int32Value 10 | 5: required i64 int64Value 11 | 6: required string stringValue 12 | } 13 | 14 | struct OptionalThriftStruct { 15 | 1: optional i16 int16Value 16 | 2: required bool someBool 17 | } 18 | 19 | struct SubobjectThriftStruct { 20 | 1: optional OptionalThriftStruct value 21 | 2: required i16 intValue 22 | } 23 | 24 | struct CollectiontThriftStruct { 25 | 1: optional list arrays 26 | 2: optional map maps 27 | 3: optional set sets 28 | } 29 | 30 | struct UnionClassA { 31 | 1: required string someString 32 | } 33 | struct UnionClassB { 34 | 1: required i64 someInt 35 | } 36 | union MyUnion { 37 | 1: UnionClassA unionClassA 38 | 2: UnionClassB unionClassB 39 | } 40 | struct UnionStruct { 41 | 1: required MyUnion someUnion 42 | } 43 | 44 | enum SomeEnum { 45 | AAA = 1, 46 | BBB = 2 47 | } 48 | 49 | struct EnumStruct { 50 | 1: required SomeEnum enumValue 51 | } 52 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/Fixtures.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // Fixtures.swift 6 | // TwitterApacheThriftTests 7 | // 8 | // Created on 3/25/20. 9 | // Copyright © 2020 Twitter. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | import TwitterApacheThrift 14 | 15 | extension OptionalThriftStruct { 16 | func with(int16Value: Int16?? = .some(nil), someBool: Bool? = nil) -> OptionalThriftStruct { 17 | return OptionalThriftStruct(int16Value: int16Value.flatMap({ $0 ?? self.int16Value }), someBool: someBool ?? self.someBool) 18 | } 19 | } 20 | 21 | extension SubobjectThriftStruct { 22 | func with(value: OptionalThriftStruct?? = .some(nil), intValue: Int16? = nil) -> SubobjectThriftStruct { 23 | return SubobjectThriftStruct(value: value.flatMap({ $0 ?? self.value }), 24 | intValue: intValue ?? self.intValue) 25 | } 26 | } 27 | 28 | extension CollectiontThriftStruct { 29 | func with(arrays: [Double]?? = .some(nil), maps: [String: String]?? = .some(nil), sets: Set?? = .some(nil)) -> CollectiontThriftStruct { 30 | return CollectiontThriftStruct(arrays: arrays.flatMap({ $0 ?? self.arrays }), 31 | maps: maps.flatMap({ $0 ?? self.maps }), 32 | sets: sets.flatMap({ $0 ?? self.sets })) 33 | } 34 | } 35 | 36 | enum Fixtures { 37 | static var foundationThriftStruct = FoundationThriftStruct(boolValue: false, 38 | doubleValue: 1.234, 39 | int16Value: 128, 40 | int32Value: 23, 41 | int64Value: 100293, 42 | stringValue: "some string") 43 | 44 | static var optionalThriftStruct = OptionalThriftStruct(int16Value: 12, someBool: true) 45 | 46 | static var subobjectThriftStruct = SubobjectThriftStruct(value: Fixtures.optionalThriftStruct, intValue: 50) 47 | 48 | static var collectionThriftStruct = CollectiontThriftStruct(arrays: [1.1, 2.2], 49 | maps: ["a": "asdf"], 50 | sets: [1]) 51 | 52 | static var dataStruct = DataStruct(data: Data("test".utf8), byte: 5) 53 | } 54 | 55 | struct UncodableStruct: ThriftCodable { 56 | enum CodingKeys: Int, CodingKey { 57 | case value = 1 58 | } 59 | 60 | let value: UInt64 61 | } 62 | 63 | struct DataStruct: ThriftCodable, Equatable { 64 | 65 | enum CodingKeys: Int, CodingKey { 66 | case data = 1 67 | case byte = 2 68 | } 69 | 70 | let data: Data 71 | let byte: UInt8 72 | } 73 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/MutableThriftCompactBinaryTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // MutableThriftCompactBinaryTests.swift 6 | // TwitterApacheThriftTests 7 | // 8 | // Created on 9/30/21. 9 | // Copyright © 2021 Twitter. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | import XCTest 14 | @testable import TwitterApacheThrift 15 | 16 | class MutableThriftCompactBinaryTests: XCTestCase { 17 | 18 | var binary: MutableThriftCompactBinary! 19 | 20 | override func setUp() { 21 | super.setUp() 22 | self.binary = MutableThriftCompactBinary() 23 | } 24 | 25 | func testMapMetadata() { 26 | binary.writeMapMetadata(keyType: .string, valueType: .string, count: 2) 27 | //2 items 28 | //String, String 29 | XCTAssertEqual(self.binary.getBuffer(), Data([0b10, 0b10001000])) 30 | 31 | } 32 | 33 | func testMapEmptyMetadata() { 34 | binary.writeMapMetadata(keyType: .string, valueType: .string, count: 0) 35 | XCTAssertEqual(self.binary.getBuffer(), Data([0])) 36 | } 37 | 38 | func testListMetadata() { 39 | binary.writeListMetadata(elementType: .string, count: 1) 40 | XCTAssertEqual(self.binary.getBuffer(), Data([0b11000])) 41 | } 42 | 43 | func testListLargeMetadata() { 44 | binary.writeListMetadata(elementType: .structure, count: 16) 45 | XCTAssertEqual(self.binary.getBuffer(), Data([0b11111100, 0b10000])) 46 | } 47 | 48 | func testFieldMetadata() { 49 | binary.writeFieldBegin(fieldType: .structure, fieldID: 15, previousId: 0) 50 | XCTAssertEqual(self.binary.getBuffer(), Data([0b11111100])) 51 | } 52 | 53 | func testFieldMetadataNonsequential() { 54 | binary.writeFieldBegin(fieldType: .structure, fieldID: 20, previousId: 0) 55 | XCTAssertEqual(self.binary.getBuffer(), Data([0b1100, 0b0, 0b101000])) 56 | } 57 | 58 | func testFieldMetadataStop() { 59 | binary.writeFieldStop() 60 | XCTAssertEqual(self.binary.getBuffer(), Data([0])) 61 | } 62 | 63 | func testDecodeDouble() { 64 | self.binary.write(1.234) 65 | XCTAssertEqual(self.binary.getBuffer(), Data([0x58, 0x39, 0xb4, 0xc8, 0x76, 0xbe, 0xf3, 0x3f])) 66 | } 67 | 68 | func testDecodeInt32() { 69 | binary.write(Int32(1234)) 70 | XCTAssertEqual(self.binary.getBuffer(), Data([0xa4, 0x13])) 71 | } 72 | 73 | func testDecodeInt64() { 74 | self.binary.write(Int64(Int32.max) + 1029) 75 | XCTAssertEqual(self.binary.getBuffer(), Data([0x88, 0x90, 0x80, 0x80, 0x10])) 76 | } 77 | 78 | func testDecodeInt16() { 79 | binary.write(Int16(829)) 80 | XCTAssertEqual(self.binary.getBuffer(), Data([0xfa, 0xc])) 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/PreencodedContainerTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // ThriftDecodingTests.swift 6 | // TwitterApacheThriftTests 7 | // 8 | // Created on 7/1/20. 9 | // Copyright © 2020 Twitter. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | import XCTest 14 | @testable import TwitterApacheThrift 15 | 16 | class PreencodedContainerTests: XCTestCase { 17 | 18 | struct TestStruct: ThriftCodable { 19 | let value: PreencodedContainer 20 | enum CodingKeys: Int, CodingKey { 21 | case value = 1 22 | } 23 | } 24 | 25 | func testEncodingData() throws { 26 | let testValue = TestStruct(value: .encodedData(Data([0, 57]))) 27 | let encoder = ThriftEncoder() 28 | let data = try encoder.encode(testValue) 29 | 30 | XCTAssertEqual(data, Data([6, 0, 1, 0, 57, 0])) 31 | } 32 | 33 | func testEncodingValue() throws { 34 | let testValue = TestStruct(value: .value(57)) 35 | let encoder = ThriftEncoder() 36 | let data = try encoder.encode(testValue) 37 | 38 | XCTAssertEqual(data, Data([6, 0, 1, 0, 57, 0])) 39 | } 40 | 41 | func testDecoding() throws { 42 | struct ValueStruct: ThriftCodable { 43 | let value: Int16 44 | enum CodingKeys: Int, CodingKey { 45 | case value = 1 46 | } 47 | } 48 | 49 | let decoder = ThriftDecoder() 50 | let testStructValue = try decoder.decode(TestStruct.self, from: Data([6, 0, 1, 0, 57, 0])) 51 | let valueStructValue = try decoder.decode(ValueStruct.self, from: Data([6, 0, 1, 0, 57, 0])) 52 | 53 | XCTAssertEqual(testStructValue.value, .value(57)) 54 | XCTAssertEqual(valueStructValue.value, 57) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Tests/TwitterApacheThriftTests/ThriftCompactBinaryTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Twitter, Inc. 2 | // Licensed under the Apache License, Version 2.0 3 | // http://www.apache.org/licenses/LICENSE-2.0 4 | // 5 | // ThriftCompactBinaryTests.swift 6 | // TwitterApacheThriftTests 7 | // 8 | // Created on 9/30/21. 9 | // Copyright © 2021 Twitter. All rights reserved. 10 | // 11 | 12 | import Foundation 13 | import XCTest 14 | @testable import TwitterApacheThrift 15 | 16 | class ThriftCompactBinaryTests: XCTestCase { 17 | 18 | var binary: ThriftCompactBinary! 19 | 20 | func testMapMetadata() throws { 21 | //2 items 22 | //String, String 23 | self.binary = ThriftCompactBinary(data: Data([0b10, 0b10001000])) 24 | let value = try binary.readMapMetadata() 25 | XCTAssertEqual(value.keyType, .string) 26 | XCTAssertEqual(value.valueType, .string) 27 | XCTAssertEqual(value.size, 2) 28 | } 29 | 30 | func testMapEmptyMetadata() throws { 31 | self.binary = ThriftCompactBinary(data: Data([0])) 32 | let value = try binary.readMapMetadata() 33 | XCTAssertEqual(value.keyType, .stop) 34 | XCTAssertEqual(value.valueType, .stop) 35 | XCTAssertEqual(value.size, 0) 36 | } 37 | 38 | func testListMetadata() throws { 39 | self.binary = ThriftCompactBinary(data: Data([0b00011000])) 40 | let value = try binary.readListMetadata() 41 | XCTAssertEqual(value.elementType, .string) 42 | XCTAssertEqual(value.size, 1) 43 | } 44 | 45 | func testListLargeMetadata() throws { 46 | self.binary = ThriftCompactBinary(data: Data([0b11111100, 0b10000])) 47 | let value = try binary.readListMetadata() 48 | XCTAssertEqual(value.elementType, .structure) 49 | XCTAssertEqual(value.size, 16) 50 | } 51 | 52 | func testFieldMetadata() throws { 53 | self.binary = ThriftCompactBinary(data: Data([0b11111100])) 54 | let value = try binary.readFieldMetadata(previousId: 0) 55 | XCTAssertEqual(value.type, .structure) 56 | XCTAssertEqual(value.id, 15) 57 | } 58 | 59 | func testFieldMetadataNonsequential() throws { 60 | self.binary = ThriftCompactBinary(data: Data([0b1100, 0, 0b101000])) 61 | let value = try binary.readFieldMetadata(previousId: 0) 62 | XCTAssertEqual(value.type, .structure) 63 | XCTAssertEqual(value.id, 20) 64 | } 65 | 66 | func testFieldMetadataStop() throws { 67 | self.binary = ThriftCompactBinary(data: Data([0])) 68 | let value = try binary.readFieldMetadata(previousId: 0) 69 | XCTAssertEqual(value.type, .stop) 70 | XCTAssertEqual(value.id, nil) 71 | } 72 | 73 | func testDecodeDouble() throws { 74 | self.binary = ThriftCompactBinary(data: Data([0x58, 0x39, 0xb4, 0xc8, 0x76, 0xbe, 0xf3, 0x3f])) 75 | let value = try binary.readDouble() 76 | XCTAssertEqual(value, 1.234) 77 | } 78 | 79 | func testDecodeInt32() throws { 80 | self.binary = ThriftCompactBinary(data: Data([0xa4, 0x13])) 81 | let value = try binary.readInt32() 82 | XCTAssertEqual(value, 1234) 83 | } 84 | 85 | func testDecodeInt64() throws { 86 | self.binary = ThriftCompactBinary(data: Data([0x88, 0x90, 0x80, 0x80, 0x10])) 87 | let value = try binary.readInt64() 88 | XCTAssertEqual(value, Int64(Int32.max) + 1029) 89 | } 90 | 91 | func testDecodeInt16() throws { 92 | self.binary = ThriftCompactBinary(data: Data([0xfa, 0xc])) 93 | let value = try binary.readInt16() 94 | XCTAssertEqual(value, 829) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | docs: 2 | @git clone https://github.com/DoccZz/docc2html.git 3 | @mkdir -p ./.build/docs/ 4 | @sh scripts/build_docs.sh 5 | @rm -rf ./build 6 | @rm -rf ./docc2html 7 | --------------------------------------------------------------------------------