RileyLinkConnectionManagerState.swift 919 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // RileyLinkConnectionManagerState.swift
  3. // RileyLinkBLEKit
  4. //
  5. // Created by Pete Schwamb on 8/21/18.
  6. // Copyright © 2018 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public struct RileyLinkConnectionManagerState: RawRepresentable, Equatable {
  10. public typealias RawValue = RileyLinkConnectionManager.RawStateValue
  11. public var autoConnectIDs: Set<String>
  12. public init(autoConnectIDs: Set<String>) {
  13. self.autoConnectIDs = autoConnectIDs
  14. }
  15. public init?(rawValue: RileyLinkConnectionManager.RawStateValue) {
  16. guard
  17. let autoConnectIDs = rawValue["autoConnectIDs"] as? [String]
  18. else {
  19. return nil
  20. }
  21. self.init(autoConnectIDs: Set(autoConnectIDs))
  22. }
  23. public var rawValue: RawValue {
  24. return [
  25. "autoConnectIDs": Array(autoConnectIDs),
  26. ]
  27. }
  28. }