2
0

gRPC.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright 2016, 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. #if SWIFT_PACKAGE
  17. import CgRPC
  18. #endif
  19. public final class gRPC {
  20. private init() { } // Static members only.
  21. /// Initializes gRPC system
  22. public static func initialize() {
  23. grpc_init()
  24. }
  25. /// Shuts down gRPC system
  26. public static func shutdown() {
  27. grpc_shutdown()
  28. }
  29. /// Returns version of underlying gRPC library
  30. public static var version: String {
  31. // These two should always be valid UTF-8 strings, so we can forcibly unwrap them.
  32. return String(cString: grpc_version_string(), encoding: .utf8)!
  33. }
  34. /// Returns name associated with gRPC version
  35. public static var gStandsFor: String {
  36. return String(cString: grpc_g_stands_for(), encoding: .utf8)!
  37. }
  38. }