Skip to content

Commit 22f3feb

Browse files
Sources/RSocketCore/Extensions/RequestExamples.swift changes
1 parent 0007072 commit 22f3feb

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

Sources/RSocketCore/Extensions/RequestExamples.swift

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
/**
18-
This file contains examples of the `Coder`, `Encoder` and `Decoder` API.
19-
All those examples should eventually be moved to documentation and/or tests.
18+
This file contains examples of the `Coder`, `Encoder` and `Decoder` API.
19+
All those examples should eventually be moved to documentation and/or tests.
2020
For now they are here to make sure we do not accidentally break any public API during development.
2121
*/
2222

@@ -51,8 +51,8 @@ fileprivate enum Requests {
5151
.encodeStaticMetadata("metrics", using: RoutingEncoder())
5252
.encodeData(using: JSONDataEncoder(type: Metrics.self))
5353
}
54-
/// Same as above but gives the call site the option to encode additional dynamic metadata
55-
static let metrics3 = FireAndForget<([CompositeMetadata], Metrics)> {
54+
/// Same as above but gives the call site the option to encode additional dynamic metadata
55+
static let metrics3 = FireAndForget<((),Metrics)> {
5656
Encoder()
5757
.useCompositeMetadata()
5858
.encodeStaticMetadata("metrics", using: RoutingEncoder())
@@ -67,7 +67,6 @@ fileprivate enum Requests {
6767
static let priceRequest1 = RequestResponse<String, Double> {
6868
Encoder()
6969
.useCompositeMetadata()
70-
.encodeStaticMetadata("price", using: RoutingEncoder())
7170
.encodeStaticMetadata([.applicationJson], using: AcceptableDataMIMETypeEncoder())
7271
.encodeData(using: JSONDataEncoder(type: Stock.self))
7372
.mapData(Stock.init(isin:))
@@ -76,7 +75,7 @@ fileprivate enum Requests {
7675
.decodeData(using: JSONDataDecoder(type: Price.self))
7776
.mapData(\.price)
7877
}
79-
/// Same as above but we do no longer need to explicitly encode the Acceptable Data MIME Type.
78+
/// Same as above but we do no longer need to explicitly encode the Acceptable Data MIME Type.
8079
/// This is because we use the `Coder` convenience API which is a thin wrapper around an `Encoder` and `Decoder`.
8180
/// `Coder.decodeData(decoder:)` takes multiple decoders and automatically encodes their MIME Type as Acceptable Data MIME Type Metadata.
8281
/// It also looks for Data MIME Type and the Connection MIME Type and choose the correct decoder during decoding.
@@ -85,23 +84,21 @@ fileprivate enum Requests {
8584
.useCompositeMetadata()
8685
.encodeStaticMetadata("price", using: RoutingEncoder())
8786
.encodeData(using: JSONDataEncoder(type: ISIN.self).map(ISIN.init(isin:)))
88-
.decodeData {
89-
JSONDataDecoder(type: Price.self).map(\.price)
90-
}
87+
.decodeData (using:JSONDataDecoder(type: Price.self).map(\.price))
9188
}
9289

9390
/// Same as above but this time the encoder also encodes the MIME Type of the data as Date MIME Type Metadata because we use the `encodeData(encoder:)` method which can take multiple encoders. The call side need to specify which encoding it wants to use.
94-
static let priceRequest3 = RequestResponse<(MIMEType, String), Double> {
91+
static let priceRequest3 = RequestResponse<(String), Double> {
9592
Coder()
9693
.useCompositeMetadata()
9794
.encodeStaticMetadata("price", using: RoutingEncoder())
98-
.encodeData {
95+
.encodeData (using:
9996
JSONDataEncoder(type: ISIN.self).map(ISIN.init(isin:))
100-
}
101-
.decodeData {
97+
)
98+
.decodeData (using:
10299
JSONDataDecoder(type: Price.self)
103100
.map(\.price)
104-
}
101+
)
105102
}
106103
/// Works with `RequestStream` and `RequestChannel` too
107104
static let priceStream1 = RequestStream<ISIN, Price> {

0 commit comments

Comments
 (0)