mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
* Remove messagepack submodule * Migrate MessagePack fork to this repo * Disable build CI * Disable Renovate * Disable Crowdin recurring job * Address workflow linter errors
21 lines
609 B
Swift
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))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|