File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Tests/GRPCInProcessTransportTests Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 17
17
import GRPCCore
18
18
import GRPCInProcessTransport
19
19
import Testing
20
+ import struct Foundation. Data
21
+ import class Foundation. JSONDecoder
22
+ import class Foundation. JSONEncoder
20
23
21
24
@Suite ( " InProcess transport " )
22
25
struct InProcessTransportTests {
@@ -172,14 +175,16 @@ private struct PeerInfo: Codable {
172
175
}
173
176
174
177
private struct PeerInfoSerializer : MessageSerializer {
175
- func serialize( _ message: PeerInfo ) throws -> [ UInt8 ] {
176
- Array ( " \( message. local) \( message. remote) " . utf8)
178
+ func serialize< Bytes : GRPCContiguousBytes > ( _ message: PeerInfo ) throws -> Bytes {
179
+ Bytes ( " \( message. local) \( message. remote) " . utf8)
177
180
}
178
181
}
179
182
180
183
private struct PeerInfoDeserializer : MessageDeserializer {
181
- func deserialize( _ serializedMessageBytes: [ UInt8 ] ) throws -> PeerInfo {
182
- let stringPeerInfo = String ( decoding: serializedMessageBytes, as: UTF8 . self)
184
+ func deserialize< Bytes: GRPCContiguousBytes > ( _ serializedMessageBytes: Bytes ) throws -> PeerInfo {
185
+ let stringPeerInfo = serializedMessageBytes. withUnsafeBytes {
186
+ String ( decoding: $0, as: UTF8 . self)
187
+ }
183
188
let peerInfoComponents = stringPeerInfo. split ( separator: " " )
184
189
return PeerInfo ( local: String ( peerInfoComponents [ 0 ] ) , remote: String ( peerInfoComponents [ 1 ] ) )
185
190
}
You can’t perform that action at this time.
0 commit comments