1515import struct Foundation. Data
1616import NIO
1717
18- // ==== ----------------------------------------------------------------------------------------------------------------
19- // MARK: Actor Message
20-
21- public typealias ActorMessage = Codable // FIXME: MAKE THIS SENDABLE: & Sendable
22-
2318/// A `Never` can never be sent as message, even more so over the wire.
24- extension Never : NonTransportableActorMessage { }
19+ extension Never : NotActuallyCodableMessage { }
2520
2621// ==== ----------------------------------------------------------------------------------------------------------------
2722// MARK: Common utility messages
2823
2924// FIXME: we should not add Codable conformance onto a stdlib type, but rather fix this in stdlib
30- extension Result : ActorMessage where Success: ActorMessage , Failure: ActorMessage {
25+ extension Result : Codable where Success: Codable , Failure: Codable {
3126 public enum DiscriminatorKeys : String , Codable {
3227 case success
3328 case failure
@@ -63,7 +58,7 @@ extension Result: ActorMessage where Success: ActorMessage, Failure: ActorMessag
6358}
6459
6560/// Generic transportable Error type, can be used to wrap error types and represent them as best as possible for transporting.
66- public struct ErrorEnvelope : Error , ActorMessage {
61+ public struct ErrorEnvelope : Error , Codable {
6762 public typealias CodableError = Error & Codable
6863
6964 private let codableError : CodableError
@@ -133,7 +128,7 @@ public struct BestEffortStringError: Error, Codable, Equatable, CustomStringConv
133128}
134129
135130/// Useful error wrapper which performs an best effort Error serialization as configured by the actor system.
136- public struct NonTransportableAnyError : Error , NonTransportableActorMessage {
131+ public struct NonTransportableAnyError : Error , NotActuallyCodableMessage {
137132 public let failure : Error
138133
139134 public init < Failure: Error > ( _ failure: Failure ) {
@@ -144,8 +139,7 @@ public struct NonTransportableAnyError: Error, NonTransportableActorMessage {
144139// ==== ----------------------------------------------------------------------------------------------------------------
145140// MARK: Not Transportable Actor Message (i.e. "local only")
146141
147- /// Marks a type as `ActorMessage` however
148- /// Attempting to send such message to a remote actor WILL FAIL and log an error.
142+ /// Marks a type as `Codable` however attempting to send such message to a remote actor WILL FAIL and log an error.
149143///
150144/// Use this with great caution and only for messages which are specifically designed to utilize the local assumption.
151145///
@@ -156,22 +150,22 @@ public struct NonTransportableAnyError: Error, NonTransportableActorMessage {
156150/// No serializer is expected to be registered for such types.
157151///
158152/// - Warning: Attempting to send such message over the network will fail at runtime (and log an error or warning).
159- public protocol NonTransportableActorMessage : ActorMessage { }
153+ public protocol NotActuallyCodableMessage : Codable { }
160154
161- extension NonTransportableActorMessage {
155+ extension NotActuallyCodableMessage {
162156 public init ( from decoder: Swift . Decoder ) throws {
163- fatalError ( " Attempted to decode NonTransportableActorMessage message: \( Self . self) ! This should never happen. " )
157+ fatalError ( " Attempted to decode NotActuallyCodableMessage message: \( Self . self) ! This should never happen. " )
164158 }
165159
166160 public func encode( to encoder: Swift . Encoder ) throws {
167- fatalError ( " Attempted to encode NonTransportableActorMessage message: \( Self . self) ! This should never happen. " )
161+ fatalError ( " Attempted to encode NotActuallyCodableMessage message: \( Self . self) ! This should never happen. " )
168162 }
169163
170164 public init ( context: Serialization . Context , from buffer: inout ByteBuffer , using manifest: Serialization . Manifest ) throws {
171- fatalError ( " Attempted to deserialize NonTransportableActorMessage message: \( Self . self) ! This should never happen. " )
165+ fatalError ( " Attempted to deserialize NotActuallyCodableMessage message: \( Self . self) ! This should never happen. " )
172166 }
173167
174168 public func serialize( context: Serialization . Context , to bytes: inout ByteBuffer ) throws {
175- fatalError ( " Attempted to serialize NonTransportableActorMessage message: \( Self . self) ! This should never happen. " )
169+ fatalError ( " Attempted to serialize NotActuallyCodableMessage message: \( Self . self) ! This should never happen. " )
176170 }
177171}
0 commit comments