diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-11-29 20:13:23 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-11-29 20:13:23 -0800 |
| commit | 30255476781789df318a571622ab732681696139 (patch) | |
| tree | 7e05705c09c1a455ca6573af686f9eb0629df894 /Hotline/Utility/DataExtensions.swift | |
| parent | 2bdcc0c3d751d7c7626d8b0e9f79331b803c668b (diff) | |
Further work on protocol.
Diffstat (limited to 'Hotline/Utility/DataExtensions.swift')
| -rw-r--r-- | Hotline/Utility/DataExtensions.swift | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Hotline/Utility/DataExtensions.swift b/Hotline/Utility/DataExtensions.swift index 3f7101b..caf26a9 100644 --- a/Hotline/Utility/DataExtensions.swift +++ b/Hotline/Utility/DataExtensions.swift @@ -6,6 +6,21 @@ enum Endianness { } extension Data { + init(_ val: UInt8) { + self.init() + self.appendUInt8(val) + } + + init(_ val: UInt16) { + self.init() + self.appendUInt16(val) + } + + init(_ val: UInt32) { + self.init() + self.appendUInt32(val) + } + func readUInt8(at offset: Int) -> UInt8? { guard offset >= 0, offset + MemoryLayout<UInt8>.size <= self.count else { return nil |