Skip to content

Commit 9d3e5b8

Browse files
authored
Revert "Relax type constraints to Encodable and Decodable" (#22)
This reverts #18 (commit 72cbab5).
1 parent 72cbab5 commit 9d3e5b8

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

Sources/KituraContracts/ClosureAliases.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,49 @@ The following two typealiases make use of `ResultClosure`:
2929
public typealias ResultClosure = (RequestError?) -> Void
3030

3131
/**
32-
The `CodableResultClosure` is used by other `Codable` aliases when responding with an object which conforms to `Encodable`, or a `RequestError` is needed.
32+
The `CodableResultClosure` is used by other `Codable` aliases when responding with an object which conforms to `Codable`, or a `RequestError` is needed.
3333

3434
The following two typealiases make use of `CodableResultClosure`:
3535
````swift
36-
public typealias IdentifierCodableClosure<Id: Identifier, I: Decodable, O: Encodable> = (Id, I, @escaping CodableResultClosure<O>) -> Void
36+
public typealias IdentifierCodableClosure<Id: Identifier, I: Codable, O: Codable> = (Id, I, @escaping CodableResultClosure<O>) -> Void
3737

38-
public typealias CodableClosure<I: Decodable, O: Encodable> = (I, @escaping CodableResultClosure<O>) -> Void
38+
public typealias CodableClosure<I: Codable, O: Codable> = (I, @escaping CodableResultClosure<O>) -> Void
3939
````
4040
*/
41-
public typealias CodableResultClosure<O: Encodable> = (O?, RequestError?) -> Void
41+
public typealias CodableResultClosure<O: Codable> = (O?, RequestError?) -> Void
4242

4343
/**
44-
The `CodableArrayResultClosure` is used by other `Codable` aliases when responding with an array of objects which conform to `Encodable`, or a `RequestError` is needed.
44+
The `CodableArrayResultClosure` is used by other `Codable` aliases when responding with an array of objects which conform to `Codable`, or a `RequestError` is needed.
4545

4646
The following typealias makes use of `CodableArrayResultClosure`:
4747
````swift
48-
public typealias CodableArrayClosure<O: Encodable> = (@escaping CodableArrayResultClosure<O>) -> Void
48+
public typealias CodableArrayClosure<O: Codable> = (@escaping CodableArrayResultClosure<O>) -> Void
4949
````
5050
*/
51-
public typealias CodableArrayResultClosure<O: Encodable> = ([O]?, RequestError?) -> Void
51+
public typealias CodableArrayResultClosure<O: Codable> = ([O]?, RequestError?) -> Void
5252

5353
/**
54-
The `IdentifierCodableArrayResultClosure` is used by other `Codable` aliases when responding with an array of tuples containing an identifier and an `Encodable` object, or a `RequestError`.
54+
The `IdentifierCodableArrayResultClosure` is used by other `Codable` aliases when responding with an array of tuples containing an identifier and a `Codable` object, or a `RequestError`.
5555

5656
The following typealias makes use of `IdentifierCodableArrayResultClosure`:
5757
````swift
58-
public typealias CodableIdentifierClosure<I: Decodable, Id: Identifier, O: Encodable> = (I, @escaping IdentifierCodableResultClosure<[Id, O]?>) -> Void
58+
public typealias CodableIdentifierClosure<I: Codable, Id: Identifier, O: Codable> = (I, @escaping IdentifierCodableResultClosure<[Id, O]?>) -> Void
5959
````
6060
*/
61-
public typealias IdentifierCodableArrayResultClosure<Id: Identifier, O:Encodable> = ([(Id, O)]?, RequestError?) -> Void
61+
public typealias IdentifierCodableArrayResultClosure<Id: Identifier, O: Codable> = ([(Id, O)]?, RequestError?) -> Void
6262

6363
/**
64-
This is used to perform a series of actions which use an object conforming to `Identifier` and an object conforming to `Decodable`. After which you want to respond with an object which conforms to `Encodable`, which is typically of the same type as the object passed as a parameter, or respond with an `Identifier` or `RequestError`.
64+
This is used to perform a series of actions which use an object conforming to `Identifier` and an object conforming to `Codable`. After which you want to respond with an object which conforms to `Codable`, which is of the same type as the object passed as a parameter, or respond with an `Identifier` or `RequestError`.
6565

6666
The following typealias makes use of `IdentifierCodableResultClosure`:
6767
````swift
68-
public typealias CodableIdentifierClosure<I: Decodable, Id: Identifier, O: Encodable> = (I, @escaping IdentifierCodableResultClosure<Id, O>) -> Void
68+
public typealias CodableIdentifierClosure<I: Codable, Id: Identifier, O: Codable> = (I, @escaping IdentifierCodableResultClosure<Id, O>) -> Void
6969
````
7070
*/
71-
public typealias IdentifierCodableResultClosure<Id: Identifier, O: Encodable> = (Id?, O?, RequestError?) -> Void
71+
public typealias IdentifierCodableResultClosure<Id: Identifier, O: Codable> = (Id?, O?, RequestError?) -> Void
7272

7373
/**
74-
The `IdentifierCodableClosure` is used to perform a series of actions utilising an object conforming to `Identifier` and an object conforming to `Decodable`, then respond with an object which conforms to `Encodable`, which is typically of the same type as the object passed as a parameter, or responding with a `RequestError` in the form of a `CodableResultClosure`.
74+
The `IdentifierCodableClosure` is used to perform a series of actions utilising an object conforming to `Identifier` and an object conforming to 'Codable', then respond with an object which conforms to `Codable`, which is of the same type as the object passed as a parameter, or responding with a `RequestError` in the form of a `CodableResultClosure`.
7575

7676
By default `Int` has conformity to `Identifier`. In this example, if there has been an error you can use the `respondWith` call to respond with an appropriate error, passing nil for the `User?`. If no errors occurred and you have a `User`, you can just respond with the user, passing nil as the `RequestError?` value.
7777
### Usage Example: ###
@@ -94,10 +94,10 @@ router.put("/users") { (id: Int, user: User, respondWith: (User?, RequestError?)
9494
}
9595
````
9696
*/
97-
public typealias IdentifierCodableClosure<Id: Identifier, I: Decodable, O: Encodable> = (Id, I, @escaping CodableResultClosure<O>) -> Void
97+
public typealias IdentifierCodableClosure<Id: Identifier, I: Codable, O: Codable> = (Id, I, @escaping CodableResultClosure<O>) -> Void
9898

9999
/**
100-
The `CodableClosure` is used to perform a series of actions utilising an object conforming to `Decodable`, then respond with an object which conforms to `Encodable`, which is typically of the same type as the object passed as a parameter, or responding with a `RequestError` in the form of a `CodableResultClosure`.
100+
The `CodableClosure` is used to perform a series of actions utilising an object conforming to `Identifier`, then respond with an object which conforms to `Codable`, which is of the same type as the object passed as a parameter, or responding with a `RequestError` in the form of a `CodableResultClosure`.
101101

102102
If no errors occurred and you have a `User`, you can just respond with the user by passing nil as the `RequestError?` value. In this example, if there has been an error you can use the `respondWith` call to respond with an appropriate error and passing nil for the `User?`.
103103
### Usage Example: ###
@@ -117,10 +117,10 @@ router.post("/users") { (user: User, respondWith: (User?, RequestError?) -> Void
117117
}
118118
````
119119
*/
120-
public typealias CodableClosure<I: Decodable, O: Encodable> = (I, @escaping CodableResultClosure<O>) -> Void
120+
public typealias CodableClosure<I: Codable, O: Codable> = (I, @escaping CodableResultClosure<O>) -> Void
121121

122122
/**
123-
The `CodableIdentifierClosure` is used to perform a series of actions utilising an object conforming to `Identifier` and an object conforming to `Decodable`, then respond with an object which conforms to `Encodable`, and/or an object conforming to `Identifier` or responding with a `RequestError` in the form of a `IdentifierCodableResultClosure`.
123+
The `CodableIdentifierClosure` is used to perform a series of actions utilising an object conforming to `Identifier`, then respond with an object which conforms to `Codable`, and/or an object conforming to `Identifier` or responding with a `RequestError` in the form of a `IdentifierCodableResultClosure`.
124124

125125
If no errors occurred and you have a `User` and the corresponding identifier, you can just respond with the identifier and user, and pass nil as the `RequestError?` value. In this example, if there has been an error you can use the `respondWith` call to respond with an appropriate error and passing nil for `Int?` and nil for `User?`.
126126
### Usage Example: ###
@@ -140,7 +140,7 @@ router.post("/users") { (user: User, respondWith: (Int?, User?, RequestError?) -
140140
}
141141
````
142142
*/
143-
public typealias CodableIdentifierClosure<I: Decodable, Id: Identifier, O: Encodable> = (I, @escaping IdentifierCodableResultClosure<Id, O>) -> Void
143+
public typealias CodableIdentifierClosure<I: Codable, Id: Identifier, O: Codable> = (I, @escaping IdentifierCodableResultClosure<Id, O>) -> Void
144144

145145
/**
146146
The `NonCodableClosure` is used to perform a series of actions then respond with a `RequestError` in the form of a `ResultClosure`.
@@ -181,7 +181,7 @@ router.delete("/users") { (id: Int, respondWith: (RequestError?) -> Void) in
181181
public typealias IdentifierNonCodableClosure<Id: Identifier> = (Id, @escaping ResultClosure) -> Void
182182

183183
/**
184-
The `CodableArrayClosure` is used to perform a series of actions then respond with an array of objects conforming to `Encodable` or a `RequestError` in the form of a `CodableArrayResultClosure`.
184+
The `CodableArrayClosure` is used to perform a series of actions then respond with an array of objects conforming to `Codable` or a `RequestError` in the form of a `CodableArrayResultClosure`.
185185

186186
If no errors occurred and you have an array of `Users` you can just respond with the users by passing nil as the `RequestError?` value. In this example, if there has been an error you can use the `respondWith` call to respond with an appropriate error and passing nil for the `[User]?`.
187187
### Usage Example: ###
@@ -197,10 +197,10 @@ router.get("/users") { (respondWith: ([User]?, RequestError?) -> Void) in
197197
}
198198
````
199199
*/
200-
public typealias CodableArrayClosure<O: Encodable> = (@escaping CodableArrayResultClosure<O>) -> Void
200+
public typealias CodableArrayClosure<O: Codable> = (@escaping CodableArrayResultClosure<O>) -> Void
201201

202202
/**
203-
The `IdentifierCodableArrayClosure` is used to perform a series of actions then respond with an array of tuples containing an identifier and an `Encodable` object, or a `RequestError`, in the form of a `IdentifierCodableArrayResultClosure`.
203+
The `IdentifierCodableArrayClosure` is used to perform a series of actions then respond with an array of tuples containing an identifier and a Codable object, or a `RequestError`, in the form of a `IdentifierCodableArrayResultClosure`.
204204

205205
If no errors occurred and you have an array of `Users` you can just respond with the users by passing nil as the `RequestError?` value. In this example, if there has been an error you can use the `respondWith` call to respond with an appropriate error and passing nil for the `[User]?`.
206206
### Usage Example: ###
@@ -216,10 +216,10 @@ public typealias CodableArrayClosure<O: Encodable> = (@escaping CodableArrayResu
216216
}
217217
````
218218
*/
219-
public typealias IdentifierCodableArrayClosure<Id: Identifier, O: Encodable> = (@escaping IdentifierCodableArrayResultClosure<Id, O>) -> Void
219+
public typealias IdentifierCodableArrayClosure<Id: Identifier, O: Codable> = (@escaping IdentifierCodableArrayResultClosure<Id, O>) -> Void
220220

221221
/**
222-
The `SimpleCodableClosure` is used to perform a series of actions, then respond with an object conforming to `Encodable` or a `RequestError` in the form of a `CodableResultClosure`.
222+
The `SimpleCodableClosure` is used to perform a series of actions, then respond with an object conforming to `Codable` or a `RequestError` in the form of a `CodableResultClosure`.
223223

224224
### Usage Example: ###
225225
````swift
@@ -233,10 +233,10 @@ router.get("/status") { (respondWith: (Status?, RequestError?) -> Void) in
233233
}
234234
````
235235
*/
236-
public typealias SimpleCodableClosure<O: Encodable> = (@escaping CodableResultClosure<O>) -> Void
236+
public typealias SimpleCodableClosure<O: Codable> = (@escaping CodableResultClosure<O>) -> Void
237237

238238
/**
239-
The `IdentifierSimpleCodableClosure` is used to perform a series of actions utilising an object which conforms to `Identifier`, then respond with an object conforming to `Encodable` or a `RequestError` in the form of a `CodableResultClosure`.
239+
The `IdentifierSimpleCodableClosure` is used to perform a series of actions utilising an object which conforms to `Identifier`, then respond with an object conforming to `Codable` or a `RequestError` in the form of a `CodableResultClosure`.
240240

241241
If there has been an error you can use the `respondWith` call to respond with an appropriate error and passing nil for the `User?`. In this example, if no errors occurred and you have a `User` you can just respond with the user by passing nil as the `RequestError?` value.
242242
### Usage Example: ###
@@ -257,4 +257,4 @@ router.get("/users") { (id: Int, respondWith: (User?, RequestError?) -> Void) in
257257
}
258258
````
259259
*/
260-
public typealias IdentifierSimpleCodableClosure<Id: Identifier, O: Encodable> = (Id, @escaping CodableResultClosure<O>) -> Void
260+
public typealias IdentifierSimpleCodableClosure<Id: Identifier, O: Codable> = (Id, @escaping CodableResultClosure<O>) -> Void

0 commit comments

Comments
 (0)