RPCParts.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2023, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /// Part of a request sent from a client to a server in a stream.
  17. public enum RPCRequestPart<Bytes: GRPCContiguousBytes> {
  18. /// Key-value pairs sent at the start of a request stream. Only one ``metadata(_:)`` value may
  19. /// be sent to the server.
  20. case metadata(Metadata)
  21. /// The bytes of a serialized message to send to the server. A stream may have any number of
  22. /// messages sent on it. Restrictions for unary request or response streams are imposed at a
  23. /// higher level.
  24. case message(Bytes)
  25. }
  26. extension RPCRequestPart: Sendable where Bytes: Sendable {}
  27. extension RPCRequestPart: Hashable where Bytes: Hashable {}
  28. extension RPCRequestPart: Equatable where Bytes: Equatable {}
  29. /// Part of a response sent from a server to a client in a stream.
  30. public enum RPCResponsePart<Bytes: GRPCContiguousBytes> {
  31. /// Key-value pairs sent at the start of the response stream. At most one ``metadata(_:)`` value
  32. /// may be sent to the client. If the server sends ``metadata(_:)`` it must be the first part in
  33. /// the response stream.
  34. case metadata(Metadata)
  35. /// The bytes of a serialized message to send to the client. A stream may have any number of
  36. /// messages sent on it. Restrictions for unary request or response streams are imposed at a
  37. /// higher level.
  38. case message(Bytes)
  39. /// A status and key-value pairs sent to the client at the end of the response stream. Every
  40. /// response stream must have exactly one ``status(_:_:)`` as the final part of the request
  41. /// stream.
  42. case status(Status, Metadata)
  43. }
  44. extension RPCResponsePart: Sendable where Bytes: Sendable {}
  45. extension RPCResponsePart: Hashable where Bytes: Hashable {}
  46. extension RPCResponsePart: Equatable where Bytes: Equatable {}