Debian Codegraph @

third_party/rust/uniffi_bindgen/src/bindings/swift/templates/DataHelper.swift

raw
1 #if swift(>=5.8)
2 @_documentation(visibility: private)
3 #endif
4 fileprivate struct FfiConverterData: FfiConverterRustBuffer {
5 typealias SwiftType = Data
6
7 public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
8 let len: Int32 = try readInt(&buf)
9 return Data(try readBytes(&buf, count: Int(len)))
10 }
11
12 public static func write(_ value: Data, into buf: inout [UInt8]) {
13 let len = Int32(value.count)
14 writeInt(&buf, len)
15 writeBytes(&buf, value)
16 }
17 }