Skip to content

Commit

Permalink
Add Codable conformance for BitMaskOptionSet
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Mar 24, 2023
1 parent 2c64b3c commit 88943f1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sources/Bluetooth/BitMaskOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,20 @@ extension BitMaskOptionSet: Sequence {
return Element.from(rawValue: rawValue).makeIterator()
}
}

// MARK: - Codable

extension BitMaskOptionSet: Decodable where Self.RawValue: Decodable {

public init(from decoder: Decoder) throws {
let rawValue = try RawValue.init(from: decoder)
self.init(rawValue: rawValue)
}
}

extension BitMaskOptionSet: Encodable where Self.RawValue: Encodable {

public func encode(to encoder: Encoder) throws {
try rawValue.encode(to: encoder)
}
}

0 comments on commit 88943f1

Please sign in to comment.