Skip to content

Commit d54c8fb

Browse files
Added UnreferencedStringEnumeration marker type for enumerations referenced by the spec
1 parent ff8e863 commit d54c8fb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the WebAuthn Swift open source project
4+
//
5+
// Copyright (c) 2022 the WebAuthn Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of WebAuthn Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
/// An enumeration type that is not referenced by other parts of the Web IDL because that would preclude other values from being used without updating the specification and its implementations.
16+
/// - SeeAlso: [WebAuthn Level 3 Editor's Draft §2.1.1. Enumerations as DOMString types](https://w3c.github.io/webauthn/#sct-domstring-backwards-compatibility)
17+
public protocol UnreferencedStringEnumeration: RawRepresentable, Codable, ExpressibleByStringLiteral, Hashable, Comparable where RawValue == String {
18+
init(_ rawValue: RawValue)
19+
}
20+
21+
extension UnreferencedStringEnumeration {
22+
public init(rawValue: RawValue) {
23+
self.init(rawValue)
24+
}
25+
26+
public init(stringLiteral value: String) {
27+
self.init(value)
28+
}
29+
30+
public static func < (lhs: Self, rhs: Self) -> Bool {
31+
lhs.rawValue < rhs.rawValue
32+
}
33+
}

0 commit comments

Comments
 (0)