Skip to content

Commit

Permalink
Put router serialization under SPI again
Browse files Browse the repository at this point in the history
  • Loading branch information
Joannis committed May 19, 2024
1 parent 3581986 commit 9734c7e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Sources/Hummingbird/Router/Trie/RouterTrie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public final class RouterTrie<Value: Sendable>: Sendable {
@usableFromInline
let values: [Value?]

@_documentation(visibility: internal)
public init(base: RouterPathTrieBuilder<Value>) {
@_spi(Internal) public init(base: RouterPathTrieBuilder<Value>) {
var trie = Trie()
var values: [Value?] = []

Expand Down
3 changes: 0 additions & 3 deletions Sources/Hummingbird/Router/Trie/Trie+serialize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import NIOCore

extension RouterTrie {
@inlinable
static func serialize(
_ node: RouterPathTrieBuilder<Value>.Node,
trie: inout Trie,
Expand Down Expand Up @@ -82,7 +81,6 @@ extension RouterTrie {
trie.nodes[nodeIndex].nextSiblingNodeIndex = trie.nodes.count
}

@inlinable
static func serializeChildren(
of node: RouterPathTrieBuilder<Value>.Node,
trie: inout Trie,
Expand All @@ -95,7 +93,6 @@ extension RouterTrie {
}
}

@inlinable
internal static func highestPriorityFirst(lhs: RouterPathTrieBuilder<Value>.Node, rhs: RouterPathTrieBuilder<Value>.Node) -> Bool {
lhs.key.priority > rhs.key.priority
}
Expand Down
12 changes: 3 additions & 9 deletions Sources/Hummingbird/Router/TrieRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
import HummingbirdCore

/// URI Path Trie Builder
@_documentation(visibility: internal)
public struct RouterPathTrieBuilder<Value: Sendable> {
@_spi(Internal) public struct RouterPathTrieBuilder<Value: Sendable> {
@usableFromInline
var root: Node

@_documentation(visibility: internal)
public init() {
self.root = Node(key: .null, output: nil)
}
Expand All @@ -43,7 +41,7 @@ public struct RouterPathTrieBuilder<Value: Sendable> {
}
}

internal func build() -> RouterTrie<Value> {
@_spi(Internal) public func build() -> RouterTrie<Value> {
.init(base: self)
}

Expand All @@ -52,15 +50,11 @@ public struct RouterPathTrieBuilder<Value: Sendable> {
}

/// Trie Node. Each node represents one component of a URI path
@_documentation(visibility: internal)
public final class Node {
@usableFromInline
@_spi(Internal) public final class Node {
let key: RouterPath.Element

@usableFromInline
var children: [Node]

@usableFromInline
var value: Value?

init(key: RouterPath.Element, output: Value?) {
Expand Down

0 comments on commit 9734c7e

Please sign in to comment.