16 lines
606 B
Swift
16 lines
606 B
Swift
import Foundation
|
|
|
|
public struct RouteSetDiff: Equatable, Sendable {
|
|
public let additions: Set<MeshAddress>
|
|
public let removals: Set<MeshAddress>
|
|
}
|
|
|
|
public enum HelperRouteSet {
|
|
public static func validate(_ desired: Set<MeshAddress>, local: MeshAddress, maximum: Int = 31) throws {
|
|
guard desired.count <= maximum, !desired.contains(local) else { throw UMNError.invalidFrame }
|
|
}
|
|
public static func diff(current: Set<MeshAddress>, desired: Set<MeshAddress>) -> RouteSetDiff {
|
|
.init(additions: desired.subtracting(current), removals: current.subtracting(desired))
|
|
}
|
|
}
|