1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00
Files
mobile/lib/MessagePack/Sources/MessagePack/FixedWidthInteger+Bytes.swift
Álison Fernandes a798ae0761 [PM-7014] Track MessagePack fork and turn off CI / recurring workflows (#3456)
* Remove messagepack submodule

* Migrate MessagePack fork to this repo

* Disable build CI

* Disable Renovate

* Disable Crowdin recurring job

* Address workflow linter errors
2025-01-06 18:59:54 -03:00

21 lines
609 B
Swift

extension FixedWidthInteger {
init(bytes: [UInt8]) {
self = bytes.withUnsafeBufferPointer {
$0.baseAddress!.withMemoryRebound(to: Self.self, capacity: 1) {
$0.pointee
}
}.bigEndian
}
var bytes: [UInt8] {
let capacity = MemoryLayout<Self>.size
var mutableValue = self.bigEndian
return withUnsafePointer(to: &mutableValue) {
return $0.withMemoryRebound(to: UInt8.self, capacity: capacity) {
return Array(UnsafeBufferPointer(start: $0, count: capacity))
}
}
}
}