import Foundation

extension Data {

    func convert<T>(into value: T) -> T {
        withUnsafeBytes {
            $0.baseAddress!.load(as: T.self)
        }
    }

    init<T>(from value: T) {
        var target = value
        self = Swift.withUnsafeBytes(of: &target) {
            Data($0)
        }
    }
}
