Skip to content

Commit 35aa3ca

Browse files
committed
Reduce built-in encodings and decodings to just Codable.
1 parent 450e214 commit 35aa3ca

File tree

2 files changed

+0
-494
lines changed

2 files changed

+0
-494
lines changed

Sources/Coding/Decoding.swift

Lines changed: 0 additions & 247 deletions
Original file line numberDiff line numberDiff line change
@@ -55,253 +55,6 @@ public extension TopLevelDecoder {
5555

5656
// MARK: - Build-in decodings
5757

58-
public extension Decoding where Value == UInt16 {
59-
static let singleValue = Self { decoder in
60-
let container = try decoder.singleValueContainer()
61-
return try container.decode(Value.self)
62-
}
63-
64-
static let unkeyed = Self { decoder in
65-
var container = try decoder.unkeyedContainer()
66-
return try container.decode(Value.self)
67-
}
68-
69-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
70-
.init { decoder in
71-
let container = try decoder.container(keyedBy: Key.self)
72-
return try container.decode(Value.self, forKey: key)
73-
}
74-
}
75-
}
76-
77-
public extension Decoding where Value == Int64 {
78-
static let singleValue = Self { decoder in
79-
let container = try decoder.singleValueContainer()
80-
return try container.decode(Value.self)
81-
}
82-
83-
static let unkeyed = Self { decoder in
84-
var container = try decoder.unkeyedContainer()
85-
return try container.decode(Value.self)
86-
}
87-
88-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
89-
.init { decoder in
90-
let container = try decoder.container(keyedBy: Key.self)
91-
return try container.decode(Value.self, forKey: key)
92-
}
93-
}
94-
}
95-
96-
public extension Decoding where Value == Int8 {
97-
static let singleValue = Self { decoder in
98-
let container = try decoder.singleValueContainer()
99-
return try container.decode(Value.self)
100-
}
101-
102-
static let unkeyed = Self { decoder in
103-
var container = try decoder.unkeyedContainer()
104-
return try container.decode(Value.self)
105-
}
106-
107-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
108-
.init { decoder in
109-
let container = try decoder.container(keyedBy: Key.self)
110-
return try container.decode(Value.self, forKey: key)
111-
}
112-
}
113-
}
114-
115-
public extension Decoding where Value == Double {
116-
static let singleValue = Self { decoder in
117-
let container = try decoder.singleValueContainer()
118-
return try container.decode(Value.self)
119-
}
120-
121-
static let unkeyed = Self { decoder in
122-
var container = try decoder.unkeyedContainer()
123-
return try container.decode(Value.self)
124-
}
125-
126-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
127-
.init { decoder in
128-
let container = try decoder.container(keyedBy: Key.self)
129-
return try container.decode(Value.self, forKey: key)
130-
}
131-
}
132-
}
133-
134-
public extension Decoding where Value == String {
135-
static let singleValue = Self { decoder in
136-
let container = try decoder.singleValueContainer()
137-
return try container.decode(Value.self)
138-
}
139-
140-
static let unkeyed = Self { decoder in
141-
var container = try decoder.unkeyedContainer()
142-
return try container.decode(Value.self)
143-
}
144-
145-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
146-
.init { decoder in
147-
let container = try decoder.container(keyedBy: Key.self)
148-
return try container.decode(Value.self, forKey: key)
149-
}
150-
}
151-
}
152-
153-
public extension Decoding where Value == UInt64 {
154-
static let singleValue = Self { decoder in
155-
let container = try decoder.singleValueContainer()
156-
return try container.decode(Value.self)
157-
}
158-
159-
static let unkeyed = Self { decoder in
160-
var container = try decoder.unkeyedContainer()
161-
return try container.decode(Value.self)
162-
}
163-
164-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
165-
.init { decoder in
166-
let container = try decoder.container(keyedBy: Key.self)
167-
return try container.decode(Value.self, forKey: key)
168-
}
169-
}
170-
}
171-
172-
public extension Decoding where Value == UInt8 {
173-
static let singleValue = Self { decoder in
174-
let container = try decoder.singleValueContainer()
175-
return try container.decode(Value.self)
176-
}
177-
178-
static let unkeyed = Self { decoder in
179-
var container = try decoder.unkeyedContainer()
180-
return try container.decode(Value.self)
181-
}
182-
183-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
184-
.init { decoder in
185-
let container = try decoder.container(keyedBy: Key.self)
186-
return try container.decode(Value.self, forKey: key)
187-
}
188-
}
189-
}
190-
191-
public extension Decoding where Value == Float {
192-
static let singleValue = Self { decoder in
193-
let container = try decoder.singleValueContainer()
194-
return try container.decode(Value.self)
195-
}
196-
197-
static let unkeyed = Self { decoder in
198-
var container = try decoder.unkeyedContainer()
199-
return try container.decode(Value.self)
200-
}
201-
202-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
203-
.init { decoder in
204-
let container = try decoder.container(keyedBy: Key.self)
205-
return try container.decode(Value.self, forKey: key)
206-
}
207-
}
208-
}
209-
210-
public extension Decoding where Value == UInt32 {
211-
static let singleValue = Self { decoder in
212-
let container = try decoder.singleValueContainer()
213-
return try container.decode(Value.self)
214-
}
215-
216-
static let unkeyed = Self { decoder in
217-
var container = try decoder.unkeyedContainer()
218-
return try container.decode(Value.self)
219-
}
220-
221-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
222-
.init { decoder in
223-
let container = try decoder.container(keyedBy: Key.self)
224-
return try container.decode(Value.self, forKey: key)
225-
}
226-
}
227-
}
228-
229-
public extension Decoding where Value == UInt {
230-
static let singleValue = Self { decoder in
231-
let container = try decoder.singleValueContainer()
232-
return try container.decode(Value.self)
233-
}
234-
235-
static let unkeyed = Self { decoder in
236-
var container = try decoder.unkeyedContainer()
237-
return try container.decode(Value.self)
238-
}
239-
240-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
241-
.init { decoder in
242-
let container = try decoder.container(keyedBy: Key.self)
243-
return try container.decode(Value.self, forKey: key)
244-
}
245-
}
246-
}
247-
248-
public extension Decoding where Value == Int {
249-
static let singleValue = Self { decoder in
250-
let container = try decoder.singleValueContainer()
251-
return try container.decode(Value.self)
252-
}
253-
254-
static let unkeyed = Self { decoder in
255-
var container = try decoder.unkeyedContainer()
256-
return try container.decode(Value.self)
257-
}
258-
259-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
260-
.init { decoder in
261-
let container = try decoder.container(keyedBy: Key.self)
262-
return try container.decode(Value.self, forKey: key)
263-
}
264-
}
265-
}
266-
267-
public extension Decoding where Value == Int32 {
268-
static let singleValue = Self { decoder in
269-
let container = try decoder.singleValueContainer()
270-
return try container.decode(Value.self)
271-
}
272-
273-
static let unkeyed = Self { decoder in
274-
var container = try decoder.unkeyedContainer()
275-
return try container.decode(Value.self)
276-
}
277-
278-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
279-
.init { decoder in
280-
let container = try decoder.container(keyedBy: Key.self)
281-
return try container.decode(Value.self, forKey: key)
282-
}
283-
}
284-
}
285-
286-
public extension Decoding where Value == Bool {
287-
static let singleValue = Self { decoder in
288-
let container = try decoder.singleValueContainer()
289-
return try container.decode(Value.self)
290-
}
291-
292-
static let unkeyed = Self { decoder in
293-
var container = try decoder.unkeyedContainer()
294-
return try container.decode(Value.self)
295-
}
296-
297-
static func withKey<Key: CodingKey>(_ key: Key) -> Self {
298-
.init { decoder in
299-
let container = try decoder.container(keyedBy: Key.self)
300-
return try container.decode(Value.self, forKey: key)
301-
}
302-
}
303-
}
304-
30558
public extension Decoding where Value: Decodable {
30659
static var singleValue: Self {
30760
.init { decoder in

0 commit comments

Comments
 (0)