Skip to content

Xcode 16 Compatible changes #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 82 additions & 10 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ let package = Package(
.executable(name: "vanilla-client-example", targets: ["VanillaClientExample"]),
],
dependencies: [
.package(url: "https://github.com/ReactiveCocoa/ReactiveSwift.git", from: "6.6.0"),
.package(url: "https://github.com/apple/swift-nio", from: "2.32.1"),
.package(url: "https://github.com/apple/swift-nio-extras", from: "1.8.0"),
.package(url: "https://github.com/apple/swift-nio-transport-services", from: "1.9.2"),
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.10.4"),
.package(url: "https://github.com/ReactiveCocoa/ReactiveSwift.git", from: "7.2.0"),
.package(url: "https://github.com/apple/swift-nio", from: "2.76.1"),
.package(url: "https://github.com/apple/swift-nio-extras", from: "1.24.1"),
.package(url: "https://github.com/apple/swift-nio-transport-services", from: "1.23.0"),
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.29.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.0"),
],
targets: [
Expand Down
25 changes: 11 additions & 14 deletions Sources/RSocketCore/Extensions/RequestExamples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

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

Expand Down Expand Up @@ -51,8 +51,8 @@ fileprivate enum Requests {
.encodeStaticMetadata("metrics", using: RoutingEncoder())
.encodeData(using: JSONDataEncoder(type: Metrics.self))
}
/// Same as above but gives the call site the option to encode additional dynamic metadata
static let metrics3 = FireAndForget<([CompositeMetadata], Metrics)> {
/// Same as above but gives the call site the option to encode additional dynamic metadata
static let metrics3 = FireAndForget<((),Metrics)> {
Encoder()
.useCompositeMetadata()
.encodeStaticMetadata("metrics", using: RoutingEncoder())
Expand All @@ -67,7 +67,6 @@ fileprivate enum Requests {
static let priceRequest1 = RequestResponse<String, Double> {
Encoder()
.useCompositeMetadata()
.encodeStaticMetadata("price", using: RoutingEncoder())
.encodeStaticMetadata([.applicationJson], using: AcceptableDataMIMETypeEncoder())
.encodeData(using: JSONDataEncoder(type: Stock.self))
.mapData(Stock.init(isin:))
Expand All @@ -76,7 +75,7 @@ fileprivate enum Requests {
.decodeData(using: JSONDataDecoder(type: Price.self))
.mapData(\.price)
}
/// Same as above but we do no longer need to explicitly encode the Acceptable Data MIME Type.
/// Same as above but we do no longer need to explicitly encode the Acceptable Data MIME Type.
/// This is because we use the `Coder` convenience API which is a thin wrapper around an `Encoder` and `Decoder`.
/// `Coder.decodeData(decoder:)` takes multiple decoders and automatically encodes their MIME Type as Acceptable Data MIME Type Metadata.
/// It also looks for Data MIME Type and the Connection MIME Type and choose the correct decoder during decoding.
Expand All @@ -85,23 +84,21 @@ fileprivate enum Requests {
.useCompositeMetadata()
.encodeStaticMetadata("price", using: RoutingEncoder())
.encodeData(using: JSONDataEncoder(type: ISIN.self).map(ISIN.init(isin:)))
.decodeData {
JSONDataDecoder(type: Price.self).map(\.price)
}
.decodeData (using:JSONDataDecoder(type: Price.self).map(\.price))
}

/// 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.
static let priceRequest3 = RequestResponse<(MIMEType, String), Double> {
static let priceRequest3 = RequestResponse<(String), Double> {
Coder()
.useCompositeMetadata()
.encodeStaticMetadata("price", using: RoutingEncoder())
.encodeData {
.encodeData (using:
JSONDataEncoder(type: ISIN.self).map(ISIN.init(isin:))
}
.decodeData {
)
.decodeData (using:
JSONDataDecoder(type: Price.self)
.map(\.price)
}
)
}
/// Works with `RequestStream` and `RequestChannel` too
static let priceStream1 = RequestStream<ISIN, Price> {
Expand Down
Loading