RPCParts.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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: Hashable, Sendable {
  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([UInt8])
  25. }
  26. /// Part of a response sent from a server to a client in a stream.
  27. public enum RPCResponsePart: Hashable, Sendable {
  28. /// Key-value pairs sent at the start of the response stream. At most one ``metadata(_:)`` value
  29. /// may be sent to the client. If the server sends ``metadata(_:)`` it must be the first part in
  30. /// the response stream.
  31. case metadata(Metadata)
  32. /// The bytes of a serialized message to send to the client. A stream may have any number of
  33. /// messages sent on it. Restrictions for unary request or response streams are imposed at a
  34. /// higher level.
  35. case message([UInt8])
  36. /// A status and key-value pairs sent to the client at the end of the response stream. Every
  37. /// response stream must have exactly one ``status(_:_:)`` as the final part of the request
  38. /// stream.
  39. case status(Status, Metadata)
  40. }