Debian Codegraph @

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

raw
1 #if swift(>=5.8)
2 @_documentation(visibility: private)
3 #endif
4 fileprivate struct FfiConverterBool : FfiConverter {
5 typealias FfiType = Int8
6 typealias SwiftType = Bool
7
8 public static func lift(_ value: Int8) throws -> Bool {
9 return value != 0
10 }
11
12 public static func lower(_ value: Bool) -> Int8 {
13 return value ? 1 : 0
14 }
15
16 public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
17 return try lift(readInt(&buf))
18 }
19
20 public static func write(_ value: Bool, into buf: inout [UInt8]) {
21 writeInt(&buf, lower(value))
22 }
23 }