Translator.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. /// Transforms ``CodeGenerationRequest`` objects into ``StructuredSwiftRepresentation`` objects.
  17. ///
  18. /// It represents the first step of the code generation process for IDL described RPCs.
  19. protocol Translator {
  20. /// Translates the provided ``CodeGenerationRequest`` object, into Swift code representation.
  21. /// - Parameters:
  22. /// - codeGenerationRequest: The IDL described RPCs representation.
  23. /// - accessLevel: The access level that will restrict the protocols, extensions and methods in the generated code.
  24. /// - accessLevelOnImports: Whether access levels should be included on imports.
  25. /// - client: Whether or not client code should be generated from the IDL described RPCs representation.
  26. /// - server: Whether or not server code should be generated from the IDL described RPCs representation.
  27. /// - Returns: A structured Swift representation of the generated code.
  28. /// - Throws: An error if there are issues translating the codeGenerationRequest.
  29. func translate(
  30. codeGenerationRequest: CodeGenerationRequest,
  31. accessLevel: CodeGenerator.Config.AccessLevel,
  32. accessLevelOnImports: Bool,
  33. client: Bool,
  34. server: Bool
  35. ) throws -> StructuredSwiftRepresentation
  36. }