88
99import Foundation
1010
11- public struct TLVDecoder {
11+ struct TLVDecoder {
1212
13- public static func decode( data: Data , from types: [ TLVDecodable . Type ] ) throws -> [ TLVDecodable ] {
13+ static func decode( data: Data , from types: [ TLVDecodable . Type ] ) throws -> [ TLVDecodable ] {
1414
1515 var offset = 0
1616
@@ -51,14 +51,14 @@ public struct TLVDecoder {
5151
5252// MARK: - Supporting Types
5353
54- public extension TLVDecoder {
54+ extension TLVDecoder {
5555
56- public struct DecodingContext {
56+ struct DecodingContext {
5757
58- public let offset : Int
58+ let offset : Int
5959 }
6060
61- public enum DecodingError : Swift . Error {
61+ enum DecodingError : Swift . Error {
6262
6363 case invalidSize( Int , context: DecodingContext )
6464 case invalidType( UInt8 , context: DecodingContext )
@@ -70,9 +70,9 @@ public extension TLVDecoder {
7070
7171// MARK: - Coder Convenience Extensions
7272
73- public extension TLVDecoder {
73+ extension TLVDecoder {
7474
75- public static func decode < Decodable: TLVDecodable > ( data: Data , from type: Decodable . Type ) throws -> Decodable {
75+ static func decode < Decodable: TLVDecodable > ( data: Data , from type: Decodable . Type ) throws -> Decodable {
7676
7777 let decodables = try decode ( data: data, from: [ type] )
7878
@@ -83,7 +83,7 @@ public extension TLVDecoder {
8383 return decodable
8484 }
8585
86- public static func decode < T1: TLVDecodable , T2: TLVDecodable >
86+ static func decode < T1: TLVDecodable , T2: TLVDecodable >
8787 ( data: Data , from types: ( T1 . Type , T2 . Type ) ) throws -> ( T1 , T2 ) {
8888
8989 let decodables = try decode ( data: data, from: [ types. 0 , types. 1 ] )
@@ -96,7 +96,7 @@ public extension TLVDecoder {
9696 return ( decodable1, decodable2)
9797 }
9898
99- public static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable >
99+ static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable >
100100 ( data: Data , from types: ( T1 . Type , T2 . Type , T3 . Type ) ) throws -> ( T1 , T2 , T3 ) {
101101
102102 let decodables = try decode ( data: data, from: [ types. 0 , types. 1 , types. 2 ] )
@@ -110,7 +110,7 @@ public extension TLVDecoder {
110110 return ( decodable1, decodable2, decodable3)
111111 }
112112
113- public static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable >
113+ static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable >
114114 ( data: Data , from types: ( T1 . Type , T2 . Type , T3 . Type , T4 . Type ) ) throws -> ( T1 , T2 , T3 , T4 ) {
115115
116116 let decodables = try decode ( data: data, from: [ types. 0 , types. 1 , types. 2 , types. 3 ] )
@@ -125,7 +125,7 @@ public extension TLVDecoder {
125125 return ( decodable1, decodable2, decodable3, decodable4)
126126 }
127127
128- public static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable , T5: TLVDecodable >
128+ static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable , T5: TLVDecodable >
129129 ( data: Data , from types: ( T1 . Type , T2 . Type , T3 . Type , T4 . Type , T5 . Type ) ) throws -> ( T1 , T2 , T3 , T4 , T5 ) {
130130
131131 let decodables = try decode ( data: data, from: [ types. 0 , types. 1 , types. 2 , types. 3 , types. 4 ] )
@@ -141,7 +141,7 @@ public extension TLVDecoder {
141141 return ( decodable1, decodable2, decodable3, decodable4, decodable5)
142142 }
143143
144- public static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable , T5: TLVDecodable , T6: TLVDecodable >
144+ static func decode < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable , T5: TLVDecodable , T6: TLVDecodable >
145145 ( data: Data , from types: ( T1 . Type , T2 . Type , T3 . Type , T4 . Type , T5 . Type , T6 . Type ) ) throws -> ( T1 , T2 , T3 , T4 , T5 , T6 ) {
146146
147147 let decodables = try decode ( data: data, from: [ types. 0 , types. 1 , types. 2 , types. 3 , types. 4 , types. 5 ] )
@@ -158,11 +158,11 @@ public extension TLVDecoder {
158158 return ( decodable1, decodable2, decodable3, decodable4, decodable5, decodable6)
159159 }
160160
161- public static func decodeOptional < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable , T5: TLVDecodable , T6: TLVDecodable >
161+ static func decodeOptional < T1: TLVDecodable , T2: TLVDecodable , T3: TLVDecodable , T4: TLVDecodable , T5: TLVDecodable , T6: TLVDecodable >
162162 ( data: Data , from types: ( T1 . Type , T2 . Type , T3 . Type , T4 . Type , T5 . Type , T6 . Type ) ) throws -> ( T1 ? , T2 ? , T3 ? , T4 ? , T5 ? , T6 ? ) {
163163
164164 let decodables = try decode ( data: data, from: [ types. 0 , types. 1 , types. 2 , types. 3 , types. 4 , types. 5 ] )
165- . sorted ( by: { type ( of: $0. 0 ) . typeCode. rawValue < type ( of: $0 . 1 ) . typeCode. rawValue } )
165+ . sorted ( by: { type ( of: $0) . typeCode. rawValue < type ( of: $1) . typeCode. rawValue } )
166166
167167 return ( decodables. count > 0 ? decodables [ 0 ] as? T1 : nil ,
168168 decodables. count > 1 ? decodables [ 1 ] as? T2 : nil ,
0 commit comments