Protocols
The following protocols are available globally.
-
BaggageKey
s are used as keys in aBaggage
. Their associated typeValue
guarantees type-safety. To give yourBaggageKey
an explicit name you may override thename
property.In general,
BaggageKey
s should beinternal
orprivate
to the part of a system using it.All access to baggage items should be performed through an accessor computed property defined as shown below:
/// The Key type should be internal (or private). enum TestIDKey: Baggage.Key { typealias Value = String static var nameOverride: String? { "test-id" } } extension Baggage { /// This is some useful property documentation. public internal(set) var testID: String? { get { self[TestIDKey.self] } set { self[TestIDKey.self] = newValue } } }
This pattern allows library authors fine-grained control over which values may be set, and whic only get by end-users.
See moreDeclaration
Swift
public protocol BaggageKey