// Code generated by internal/mobile/wire/gen from spec.go; DO NOT EDIT. // swiftlint:disable all /// Writes the values of a message, as package wire encodes them. public struct WireWriter { public var buf: [UInt8] = [] public init() {} mutating func uvarint(_ v: UInt64) { var v = v while v >= 0x80 { buf.append(UInt8(v & 0x7f) | 0x80); v >>= 7 } buf.append(UInt8(v)) } mutating func int(_ v: Int) { uvarint(UInt64(bitPattern: Int64((v << 1) ^ (v >> 63)))) } mutating func bool(_ v: Bool) { buf.append(v ? 1 : 0) } mutating func float(_ v: Double) { withUnsafeBytes(of: v.bitPattern.littleEndian) { buf.append(contentsOf: $0) } } mutating func string(_ v: String) { let u = Array(v.utf8); uvarint(UInt64(u.count)); buf.append(contentsOf: u) } mutating func bytes(_ v: [UInt8]) { uvarint(UInt64(v.count)); buf.append(contentsOf: v) } mutating func strings(_ v: [String]) { uvarint(UInt64(v.count)); for s in v { string(s) } } mutating func floats(_ v: [Double]) { uvarint(UInt64(v.count)); for f in v { float(f) } } } /// Reads the values of a message; past its end they read as zero. public struct WireReader { let buf: UnsafeRawBufferPointer var at = 0 public init(_ buf: UnsafeRawBufferPointer) { self.buf = buf } mutating func uvarint() -> UInt64 { var v: UInt64 = 0, shift: UInt64 = 0 while at < buf.count { let c = buf[at]; at += 1 v |= UInt64(c & 0x7f) << shift if c < 0x80 { return v } shift += 7 } return 0 } mutating func int() -> Int { let u = uvarint(); return Int(Int64(bitPattern: (u >> 1) ^ (0 &- (u & 1)))) } mutating func bool() -> Bool { guard at < buf.count else { return false }; at += 1; return buf[at - 1] != 0 } mutating func float() -> Double { guard at + 8 <= buf.count else { at = buf.count; return 0 } var bits: UInt64 = 0 for i in 0..<8 { bits |= UInt64(buf[at + i]) << (8 * UInt64(i)) } at += 8 return Double(bitPattern: bits) } mutating func bytes() -> [UInt8] { let n = Int(uvarint()) guard n >= 0, at + n <= buf.count else { at = buf.count; return [] } defer { at += n } return Array(buf[at.. String { String(decoding: bytes(), as: UTF8.self) } mutating func strings() -> [String] { let n = Int(uvarint()) var s: [String] = [] for _ in 0.. [Double] { let n = Int(uvarint()) var f: [Double] = [] for _ in 0..