From ee0dce574bab6264e6f1338dc5175eb2e74eca10 Mon Sep 17 00:00:00 2001 From: Joannis Orlandos Date: Mon, 13 May 2024 13:48:40 +0200 Subject: [PATCH] Make the router's API public for use in benchmarks --- Benchmarks/Benchmarks/Router/RouterBenchmarks.swift | 2 +- Sources/Hummingbird/Router/Trie/RouterTrie.swift | 7 ++++--- Sources/Hummingbird/Router/Trie/Trie+resolve.swift | 4 ++-- Sources/Hummingbird/Router/TrieRouter.swift | 7 +++++-- Tests/HummingbirdTests/TrieRouterTests.swift | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift b/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift index d01659877..f1fcfd56c 100644 --- a/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift +++ b/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift @@ -17,7 +17,7 @@ import HTTPTypes import Hummingbird import NIOEmbedded import NIOHTTPTypes -@_spi(Internal) import HummingbirdCore +import HummingbirdCore import Logging import NIOCore import NIOPosix diff --git a/Sources/Hummingbird/Router/Trie/RouterTrie.swift b/Sources/Hummingbird/Router/Trie/RouterTrie.swift index 5d560f55a..c3f763a1a 100644 --- a/Sources/Hummingbird/Router/Trie/RouterTrie.swift +++ b/Sources/Hummingbird/Router/Trie/RouterTrie.swift @@ -56,15 +56,16 @@ struct Trie: Sendable { init() {} } -@usableFromInline -internal final class RouterTrie: Sendable { +@_documentation(visibility: internal) +public final class RouterTrie: Sendable { @usableFromInline let trie: Trie @usableFromInline let values: [Value?] - internal init(base: RouterPathTrieBuilder) { + @_documentation(visibility: internal) + public init(base: RouterPathTrieBuilder) { var trie = Trie() var values: [Value?] = [] diff --git a/Sources/Hummingbird/Router/Trie/Trie+resolve.swift b/Sources/Hummingbird/Router/Trie/Trie+resolve.swift index bcdfdad16..383f63ae2 100644 --- a/Sources/Hummingbird/Router/Trie/Trie+resolve.swift +++ b/Sources/Hummingbird/Router/Trie/Trie+resolve.swift @@ -16,8 +16,8 @@ import NIOCore extension RouterTrie { /// Resolve a path to a `Value` if available - @usableFromInline - internal func resolve(_ path: String) -> (value: Value, parameters: Parameters)? { + @inlinable + public func resolve(_ path: String) -> (value: Value, parameters: Parameters)? { let pathComponents = path.split(separator: "/", omittingEmptySubsequences: true) var pathComponentsIterator = pathComponents.makeIterator() var parameters = Parameters() diff --git a/Sources/Hummingbird/Router/TrieRouter.swift b/Sources/Hummingbird/Router/TrieRouter.swift index bef3d775e..885bfc48f 100644 --- a/Sources/Hummingbird/Router/TrieRouter.swift +++ b/Sources/Hummingbird/Router/TrieRouter.swift @@ -15,10 +15,12 @@ import HummingbirdCore /// URI Path Trie Builder -@_spi(Internal) public struct RouterPathTrieBuilder { +@_documentation(visibility: internal) +public struct RouterPathTrieBuilder { @usableFromInline var root: Node + @_documentation(visibility: internal) public init() { self.root = Node(key: .null, output: nil) } @@ -50,7 +52,8 @@ import HummingbirdCore } /// Trie Node. Each node represents one component of a URI path - @_spi(Internal) public final class Node { + @_documentation(visibility: internal) + public final class Node { @usableFromInline let key: RouterPath.Element diff --git a/Tests/HummingbirdTests/TrieRouterTests.swift b/Tests/HummingbirdTests/TrieRouterTests.swift index 60b44515d..73e61d80b 100644 --- a/Tests/HummingbirdTests/TrieRouterTests.swift +++ b/Tests/HummingbirdTests/TrieRouterTests.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -@_spi(Internal) import Hummingbird +@testable import Hummingbird import XCTest class TrieRouterTests: XCTestCase {