32 lines
804 B
Swift
Raw Normal View History

import Foundation
public extension Data {
var uint8 : UInt8 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt8.self) }[0]
}
var uint16: UInt16 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt16.self) }[0]
}
var uint32: UInt32 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt32.self) }[0]
}
var uint64: UInt64 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt64.self) }[0]
}
var uint128: UInt128 {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt128.self) }[0]
}
var uint: UInt {
return self.withUnsafeBytes{ $0.bindMemory(to: UInt.self) }[0]
}
var timestamp: Date {
return self.withUnsafeBytes{ $0.bindMemory(to: Date.self) }[0]
}
2024-12-05 16:21:52 +01:00
}