
- Comprehensive README update documenting v2.0 architectural changes - Updated git remote to ssh://rockvilleav@git.rockvilletollandsda.church:10443/RTSDA/RTSDA-iOS.git - Documented unified ChurchService and 60% code reduction - Added new features: Home Feed, responsive reading, enhanced UI - Corrected license information (GPL v3 with church content copyright) - Updated build instructions and technical stack details
1102 lines
38 KiB
Swift
1102 lines
38 KiB
Swift
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
|
// Trust me, you don't want to mess with it!
|
|
|
|
// swiftlint:disable all
|
|
import Foundation
|
|
|
|
// Depending on the consumer's build setup, the low-level FFI code
|
|
// might be in a separate module, or it might be compiled inline into
|
|
// this module. This is a bit of light hackery to work with both.
|
|
#if canImport(church_coreFFI)
|
|
import church_coreFFI
|
|
#endif
|
|
|
|
fileprivate extension RustBuffer {
|
|
// Allocate a new buffer, copying the contents of a `UInt8` array.
|
|
init(bytes: [UInt8]) {
|
|
let rbuf = bytes.withUnsafeBufferPointer { ptr in
|
|
RustBuffer.from(ptr)
|
|
}
|
|
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
|
|
}
|
|
|
|
static func empty() -> RustBuffer {
|
|
RustBuffer(capacity: 0, len:0, data: nil)
|
|
}
|
|
|
|
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
|
|
try! rustCall { ffi_church_core_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
|
|
}
|
|
|
|
// Frees the buffer in place.
|
|
// The buffer must not be used after this is called.
|
|
func deallocate() {
|
|
try! rustCall { ffi_church_core_rustbuffer_free(self, $0) }
|
|
}
|
|
}
|
|
|
|
fileprivate extension ForeignBytes {
|
|
init(bufferPointer: UnsafeBufferPointer<UInt8>) {
|
|
self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
|
|
}
|
|
}
|
|
|
|
// For every type used in the interface, we provide helper methods for conveniently
|
|
// lifting and lowering that type from C-compatible data, and for reading and writing
|
|
// values of that type in a buffer.
|
|
|
|
// Helper classes/extensions that don't change.
|
|
// Someday, this will be in a library of its own.
|
|
|
|
fileprivate extension Data {
|
|
init(rustBuffer: RustBuffer) {
|
|
// TODO: This copies the buffer. Can we read directly from a
|
|
// Rust buffer?
|
|
self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len))
|
|
}
|
|
}
|
|
|
|
// Define reader functionality. Normally this would be defined in a class or
|
|
// struct, but we use standalone functions instead in order to make external
|
|
// types work.
|
|
//
|
|
// With external types, one swift source file needs to be able to call the read
|
|
// method on another source file's FfiConverter, but then what visibility
|
|
// should Reader have?
|
|
// - If Reader is fileprivate, then this means the read() must also
|
|
// be fileprivate, which doesn't work with external types.
|
|
// - If Reader is internal/public, we'll get compile errors since both source
|
|
// files will try define the same type.
|
|
//
|
|
// Instead, the read() method and these helper functions input a tuple of data
|
|
|
|
fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
|
|
(data: data, offset: 0)
|
|
}
|
|
|
|
// Reads an integer at the current offset, in big-endian order, and advances
|
|
// the offset on success. Throws if reading the integer would move the
|
|
// offset past the end of the buffer.
|
|
fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
|
|
let range = reader.offset..<reader.offset + MemoryLayout<T>.size
|
|
guard reader.data.count >= range.upperBound else {
|
|
throw UniffiInternalError.bufferOverflow
|
|
}
|
|
if T.self == UInt8.self {
|
|
let value = reader.data[reader.offset]
|
|
reader.offset += 1
|
|
return value as! T
|
|
}
|
|
var value: T = 0
|
|
let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
|
|
reader.offset = range.upperBound
|
|
return value.bigEndian
|
|
}
|
|
|
|
// Reads an arbitrary number of bytes, to be used to read
|
|
// raw bytes, this is useful when lifting strings
|
|
fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
|
|
let range = reader.offset..<(reader.offset+count)
|
|
guard reader.data.count >= range.upperBound else {
|
|
throw UniffiInternalError.bufferOverflow
|
|
}
|
|
var value = [UInt8](repeating: 0, count: count)
|
|
value.withUnsafeMutableBufferPointer({ buffer in
|
|
reader.data.copyBytes(to: buffer, from: range)
|
|
})
|
|
reader.offset = range.upperBound
|
|
return value
|
|
}
|
|
|
|
// Reads a float at the current offset.
|
|
fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
|
|
return Float(bitPattern: try readInt(&reader))
|
|
}
|
|
|
|
// Reads a float at the current offset.
|
|
fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
|
|
return Double(bitPattern: try readInt(&reader))
|
|
}
|
|
|
|
// Indicates if the offset has reached the end of the buffer.
|
|
fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
|
|
return reader.offset < reader.data.count
|
|
}
|
|
|
|
// Define writer functionality. Normally this would be defined in a class or
|
|
// struct, but we use standalone functions instead in order to make external
|
|
// types work. See the above discussion on Readers for details.
|
|
|
|
fileprivate func createWriter() -> [UInt8] {
|
|
return []
|
|
}
|
|
|
|
fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
|
|
writer.append(contentsOf: byteArr)
|
|
}
|
|
|
|
// Writes an integer in big-endian order.
|
|
//
|
|
// Warning: make sure what you are trying to write
|
|
// is in the correct type!
|
|
fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
|
|
var value = value.bigEndian
|
|
withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
|
|
}
|
|
|
|
fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
|
|
writeInt(&writer, value.bitPattern)
|
|
}
|
|
|
|
fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
|
|
writeInt(&writer, value.bitPattern)
|
|
}
|
|
|
|
// Protocol for types that transfer other types across the FFI. This is
|
|
// analogous to the Rust trait of the same name.
|
|
fileprivate protocol FfiConverter {
|
|
associatedtype FfiType
|
|
associatedtype SwiftType
|
|
|
|
static func lift(_ value: FfiType) throws -> SwiftType
|
|
static func lower(_ value: SwiftType) -> FfiType
|
|
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
|
|
static func write(_ value: SwiftType, into buf: inout [UInt8])
|
|
}
|
|
|
|
// Types conforming to `Primitive` pass themselves directly over the FFI.
|
|
fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
|
|
|
|
extension FfiConverterPrimitive {
|
|
public static func lift(_ value: FfiType) throws -> SwiftType {
|
|
return value
|
|
}
|
|
|
|
public static func lower(_ value: SwiftType) -> FfiType {
|
|
return value
|
|
}
|
|
}
|
|
|
|
// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
|
|
// Used for complex types where it's hard to write a custom lift/lower.
|
|
fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
|
|
|
|
extension FfiConverterRustBuffer {
|
|
public static func lift(_ buf: RustBuffer) throws -> SwiftType {
|
|
var reader = createReader(data: Data(rustBuffer: buf))
|
|
let value = try read(from: &reader)
|
|
if hasRemaining(reader) {
|
|
throw UniffiInternalError.incompleteData
|
|
}
|
|
buf.deallocate()
|
|
return value
|
|
}
|
|
|
|
public static func lower(_ value: SwiftType) -> RustBuffer {
|
|
var writer = createWriter()
|
|
write(value, into: &writer)
|
|
return RustBuffer(bytes: writer)
|
|
}
|
|
}
|
|
// An error type for FFI errors. These errors occur at the UniFFI level, not
|
|
// the library level.
|
|
fileprivate enum UniffiInternalError: LocalizedError {
|
|
case bufferOverflow
|
|
case incompleteData
|
|
case unexpectedOptionalTag
|
|
case unexpectedEnumCase
|
|
case unexpectedNullPointer
|
|
case unexpectedRustCallStatusCode
|
|
case unexpectedRustCallError
|
|
case unexpectedStaleHandle
|
|
case rustPanic(_ message: String)
|
|
|
|
public var errorDescription: String? {
|
|
switch self {
|
|
case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
|
|
case .incompleteData: return "The buffer still has data after lifting its containing value"
|
|
case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
|
|
case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
|
|
case .unexpectedNullPointer: return "Raw pointer value was null"
|
|
case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
|
|
case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
|
|
case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
|
|
case let .rustPanic(message): return message
|
|
}
|
|
}
|
|
}
|
|
|
|
fileprivate extension NSLock {
|
|
func withLock<T>(f: () throws -> T) rethrows -> T {
|
|
self.lock()
|
|
defer { self.unlock() }
|
|
return try f()
|
|
}
|
|
}
|
|
|
|
fileprivate let CALL_SUCCESS: Int8 = 0
|
|
fileprivate let CALL_ERROR: Int8 = 1
|
|
fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
|
|
fileprivate let CALL_CANCELLED: Int8 = 3
|
|
|
|
fileprivate extension RustCallStatus {
|
|
init() {
|
|
self.init(
|
|
code: CALL_SUCCESS,
|
|
errorBuf: RustBuffer.init(
|
|
capacity: 0,
|
|
len: 0,
|
|
data: nil
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
|
let neverThrow: ((RustBuffer) throws -> Never)? = nil
|
|
return try makeRustCall(callback, errorHandler: neverThrow)
|
|
}
|
|
|
|
private func rustCallWithError<T, E: Swift.Error>(
|
|
_ errorHandler: @escaping (RustBuffer) throws -> E,
|
|
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
|
try makeRustCall(callback, errorHandler: errorHandler)
|
|
}
|
|
|
|
private func makeRustCall<T, E: Swift.Error>(
|
|
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
|
|
errorHandler: ((RustBuffer) throws -> E)?
|
|
) throws -> T {
|
|
uniffiEnsureInitialized()
|
|
var callStatus = RustCallStatus.init()
|
|
let returnedVal = callback(&callStatus)
|
|
try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
|
|
return returnedVal
|
|
}
|
|
|
|
private func uniffiCheckCallStatus<E: Swift.Error>(
|
|
callStatus: RustCallStatus,
|
|
errorHandler: ((RustBuffer) throws -> E)?
|
|
) throws {
|
|
switch callStatus.code {
|
|
case CALL_SUCCESS:
|
|
return
|
|
|
|
case CALL_ERROR:
|
|
if let errorHandler = errorHandler {
|
|
throw try errorHandler(callStatus.errorBuf)
|
|
} else {
|
|
callStatus.errorBuf.deallocate()
|
|
throw UniffiInternalError.unexpectedRustCallError
|
|
}
|
|
|
|
case CALL_UNEXPECTED_ERROR:
|
|
// When the rust code sees a panic, it tries to construct a RustBuffer
|
|
// with the message. But if that code panics, then it just sends back
|
|
// an empty buffer.
|
|
if callStatus.errorBuf.len > 0 {
|
|
throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
|
|
} else {
|
|
callStatus.errorBuf.deallocate()
|
|
throw UniffiInternalError.rustPanic("Rust panic")
|
|
}
|
|
|
|
case CALL_CANCELLED:
|
|
fatalError("Cancellation not supported yet")
|
|
|
|
default:
|
|
throw UniffiInternalError.unexpectedRustCallStatusCode
|
|
}
|
|
}
|
|
|
|
private func uniffiTraitInterfaceCall<T>(
|
|
callStatus: UnsafeMutablePointer<RustCallStatus>,
|
|
makeCall: () throws -> T,
|
|
writeReturn: (T) -> ()
|
|
) {
|
|
do {
|
|
try writeReturn(makeCall())
|
|
} catch let error {
|
|
callStatus.pointee.code = CALL_UNEXPECTED_ERROR
|
|
callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
|
|
}
|
|
}
|
|
|
|
private func uniffiTraitInterfaceCallWithError<T, E>(
|
|
callStatus: UnsafeMutablePointer<RustCallStatus>,
|
|
makeCall: () throws -> T,
|
|
writeReturn: (T) -> (),
|
|
lowerError: (E) -> RustBuffer
|
|
) {
|
|
do {
|
|
try writeReturn(makeCall())
|
|
} catch let error as E {
|
|
callStatus.pointee.code = CALL_ERROR
|
|
callStatus.pointee.errorBuf = lowerError(error)
|
|
} catch {
|
|
callStatus.pointee.code = CALL_UNEXPECTED_ERROR
|
|
callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
|
|
}
|
|
}
|
|
fileprivate class UniffiHandleMap<T> {
|
|
private var map: [UInt64: T] = [:]
|
|
private let lock = NSLock()
|
|
private var currentHandle: UInt64 = 1
|
|
|
|
func insert(obj: T) -> UInt64 {
|
|
lock.withLock {
|
|
let handle = currentHandle
|
|
currentHandle += 1
|
|
map[handle] = obj
|
|
return handle
|
|
}
|
|
}
|
|
|
|
func get(handle: UInt64) throws -> T {
|
|
try lock.withLock {
|
|
guard let obj = map[handle] else {
|
|
throw UniffiInternalError.unexpectedStaleHandle
|
|
}
|
|
return obj
|
|
}
|
|
}
|
|
|
|
@discardableResult
|
|
func remove(handle: UInt64) throws -> T {
|
|
try lock.withLock {
|
|
guard let obj = map.removeValue(forKey: handle) else {
|
|
throw UniffiInternalError.unexpectedStaleHandle
|
|
}
|
|
return obj
|
|
}
|
|
}
|
|
|
|
var count: Int {
|
|
get {
|
|
map.count
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Public interface members begin here.
|
|
|
|
|
|
fileprivate struct FfiConverterDouble: FfiConverterPrimitive {
|
|
typealias FfiType = Double
|
|
typealias SwiftType = Double
|
|
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Double {
|
|
return try lift(readDouble(&buf))
|
|
}
|
|
|
|
public static func write(_ value: Double, into buf: inout [UInt8]) {
|
|
writeDouble(&buf, lower(value))
|
|
}
|
|
}
|
|
|
|
fileprivate struct FfiConverterBool : FfiConverter {
|
|
typealias FfiType = Int8
|
|
typealias SwiftType = Bool
|
|
|
|
public static func lift(_ value: Int8) throws -> Bool {
|
|
return value != 0
|
|
}
|
|
|
|
public static func lower(_ value: Bool) -> Int8 {
|
|
return value ? 1 : 0
|
|
}
|
|
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
|
|
return try lift(readInt(&buf))
|
|
}
|
|
|
|
public static func write(_ value: Bool, into buf: inout [UInt8]) {
|
|
writeInt(&buf, lower(value))
|
|
}
|
|
}
|
|
|
|
fileprivate struct FfiConverterString: FfiConverter {
|
|
typealias SwiftType = String
|
|
typealias FfiType = RustBuffer
|
|
|
|
public static func lift(_ value: RustBuffer) throws -> String {
|
|
defer {
|
|
value.deallocate()
|
|
}
|
|
if value.data == nil {
|
|
return String()
|
|
}
|
|
let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
|
|
return String(bytes: bytes, encoding: String.Encoding.utf8)!
|
|
}
|
|
|
|
public static func lower(_ value: String) -> RustBuffer {
|
|
return value.utf8CString.withUnsafeBufferPointer { ptr in
|
|
// The swift string gives us int8_t, we want uint8_t.
|
|
ptr.withMemoryRebound(to: UInt8.self) { ptr in
|
|
// The swift string gives us a trailing null byte, we don't want it.
|
|
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
|
|
return RustBuffer.from(buf)
|
|
}
|
|
}
|
|
}
|
|
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
|
|
let len: Int32 = try readInt(&buf)
|
|
return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
|
|
}
|
|
|
|
public static func write(_ value: String, into buf: inout [UInt8]) {
|
|
let len = Int32(value.utf8.count)
|
|
writeInt(&buf, len)
|
|
writeBytes(&buf, value.utf8)
|
|
}
|
|
}
|
|
|
|
fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|
typealias SwiftType = String?
|
|
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|
guard let value = value else {
|
|
writeInt(&buf, Int8(0))
|
|
return
|
|
}
|
|
writeInt(&buf, Int8(1))
|
|
FfiConverterString.write(value, into: &buf)
|
|
}
|
|
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
switch try readInt(&buf) as Int8 {
|
|
case 0: return nil
|
|
case 1: return try FfiConverterString.read(from: &buf)
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|
}
|
|
}
|
|
}
|
|
|
|
fileprivate struct FfiConverterSequenceDouble: FfiConverterRustBuffer {
|
|
typealias SwiftType = [Double]
|
|
|
|
public static func write(_ value: [Double], into buf: inout [UInt8]) {
|
|
let len = Int32(value.count)
|
|
writeInt(&buf, len)
|
|
for item in value {
|
|
FfiConverterDouble.write(item, into: &buf)
|
|
}
|
|
}
|
|
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Double] {
|
|
let len: Int32 = try readInt(&buf)
|
|
var seq = [Double]()
|
|
seq.reserveCapacity(Int(len))
|
|
for _ in 0 ..< len {
|
|
seq.append(try FfiConverterDouble.read(from: &buf))
|
|
}
|
|
return seq
|
|
}
|
|
}
|
|
public func createCalendarEventData(eventJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_create_calendar_event_data(
|
|
FfiConverterString.lower(eventJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func createSermonShareItemsJson(title: String, speaker: String, videoUrl: String?, audioUrl: String?) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_create_sermon_share_items_json(
|
|
FfiConverterString.lower(title),
|
|
FfiConverterString.lower(speaker),
|
|
FfiConverterOptionString.lower(videoUrl),
|
|
FfiConverterOptionString.lower(audioUrl),$0
|
|
)
|
|
})
|
|
}
|
|
public func deviceSupportsAv1() -> Bool {
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_device_supports_av1($0
|
|
)
|
|
})
|
|
}
|
|
public func extractFullVerseText(versesJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_extract_full_verse_text(
|
|
FfiConverterString.lower(versesJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func extractScriptureReferencesString(scriptureText: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_extract_scripture_references_string(
|
|
FfiConverterString.lower(scriptureText),$0
|
|
)
|
|
})
|
|
}
|
|
public func extractStreamUrlFromStatus(statusJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_extract_stream_url_from_status(
|
|
FfiConverterString.lower(statusJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func fetchBibleVerseJson(query: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_bible_verse_json(
|
|
FfiConverterString.lower(query),$0
|
|
)
|
|
})
|
|
}
|
|
public func fetchBulletinsJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_bulletins_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchCachedImageBase64(url: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_cached_image_base64(
|
|
FfiConverterString.lower(url),$0
|
|
)
|
|
})
|
|
}
|
|
public func fetchConfigJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_config_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchCurrentBulletinJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_current_bulletin_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchEventsJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_events_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchFeaturedEventsJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_featured_events_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchLiveStreamJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_live_stream_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchLivestreamArchiveJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_livestream_archive_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchRandomBibleVerseJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_random_bible_verse_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchScriptureVersesForSermonJson(sermonId: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_scripture_verses_for_sermon_json(
|
|
FfiConverterString.lower(sermonId),$0
|
|
)
|
|
})
|
|
}
|
|
public func fetchSermonsJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_sermons_json($0
|
|
)
|
|
})
|
|
}
|
|
public func fetchStreamStatusJson() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_fetch_stream_status_json($0
|
|
)
|
|
})
|
|
}
|
|
public func filterSermonsByMediaType(sermonsJson: String, mediaTypeStr: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_filter_sermons_by_media_type(
|
|
FfiConverterString.lower(sermonsJson),
|
|
FfiConverterString.lower(mediaTypeStr),$0
|
|
)
|
|
})
|
|
}
|
|
public func formatEventForDisplayJson(eventJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_format_event_for_display_json(
|
|
FfiConverterString.lower(eventJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func formatScriptureTextJson(scriptureText: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_format_scripture_text_json(
|
|
FfiConverterString.lower(scriptureText),$0
|
|
)
|
|
})
|
|
}
|
|
public func formatTimeRangeString(startTime: String, endTime: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_format_time_range_string(
|
|
FfiConverterString.lower(startTime),
|
|
FfiConverterString.lower(endTime),$0
|
|
)
|
|
})
|
|
}
|
|
public func generateHomeFeedJson(eventsJson: String, sermonsJson: String, bulletinsJson: String, verseJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_generate_home_feed_json(
|
|
FfiConverterString.lower(eventsJson),
|
|
FfiConverterString.lower(sermonsJson),
|
|
FfiConverterString.lower(bulletinsJson),
|
|
FfiConverterString.lower(verseJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func generateVerseDescription(versesJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_generate_verse_description(
|
|
FfiConverterString.lower(versesJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func getAboutText() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_about_text($0
|
|
)
|
|
})
|
|
}
|
|
public func getAv1StreamingUrl(mediaId: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_av1_streaming_url(
|
|
FfiConverterString.lower(mediaId),$0
|
|
)
|
|
})
|
|
}
|
|
public func getBrandColor() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_brand_color($0
|
|
)
|
|
})
|
|
}
|
|
public func getChurchAddress() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_church_address($0
|
|
)
|
|
})
|
|
}
|
|
public func getChurchName() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_church_name($0
|
|
)
|
|
})
|
|
}
|
|
public func getContactEmail() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_contact_email($0
|
|
)
|
|
})
|
|
}
|
|
public func getContactPhone() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_contact_phone($0
|
|
)
|
|
})
|
|
}
|
|
public func getCoordinates() -> [Double] {
|
|
return try! FfiConverterSequenceDouble.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_coordinates($0
|
|
)
|
|
})
|
|
}
|
|
public func getDonationUrl() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_donation_url($0
|
|
)
|
|
})
|
|
}
|
|
public func getFacebookUrl() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_facebook_url($0
|
|
)
|
|
})
|
|
}
|
|
public func getHlsStreamingUrl(mediaId: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_hls_streaming_url(
|
|
FfiConverterString.lower(mediaId),$0
|
|
)
|
|
})
|
|
}
|
|
public func getInstagramUrl() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_instagram_url($0
|
|
)
|
|
})
|
|
}
|
|
public func getLivestreamUrl() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_livestream_url($0
|
|
)
|
|
})
|
|
}
|
|
public func getMediaTypeDisplayName(mediaTypeStr: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_media_type_display_name(
|
|
FfiConverterString.lower(mediaTypeStr),$0
|
|
)
|
|
})
|
|
}
|
|
public func getMediaTypeIcon(mediaTypeStr: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_media_type_icon(
|
|
FfiConverterString.lower(mediaTypeStr),$0
|
|
)
|
|
})
|
|
}
|
|
public func getMissionStatement() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_mission_statement($0
|
|
)
|
|
})
|
|
}
|
|
public func getOptimalStreamingUrl(mediaId: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_optimal_streaming_url(
|
|
FfiConverterString.lower(mediaId),$0
|
|
)
|
|
})
|
|
}
|
|
public func getStreamLiveStatus() -> Bool {
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_stream_live_status($0
|
|
)
|
|
})
|
|
}
|
|
public func getWebsiteUrl() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_website_url($0
|
|
)
|
|
})
|
|
}
|
|
public func getYoutubeUrl() -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_get_youtube_url($0
|
|
)
|
|
})
|
|
}
|
|
public func isMultiDayEventCheck(date: String) -> Bool {
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_is_multi_day_event_check(
|
|
FfiConverterString.lower(date),$0
|
|
)
|
|
})
|
|
}
|
|
public func parseBibleVerseFromJson(verseJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_parse_bible_verse_from_json(
|
|
FfiConverterString.lower(verseJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func parseBulletinsFromJson(bulletinsJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_parse_bulletins_from_json(
|
|
FfiConverterString.lower(bulletinsJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func parseCalendarEventData(calendarJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_parse_calendar_event_data(
|
|
FfiConverterString.lower(calendarJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func parseContactResultFromJson(resultJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_parse_contact_result_from_json(
|
|
FfiConverterString.lower(resultJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func parseEventsFromJson(eventsJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_parse_events_from_json(
|
|
FfiConverterString.lower(eventsJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func parseSermonsFromJson(sermonsJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_parse_sermons_from_json(
|
|
FfiConverterString.lower(sermonsJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func submitContactJson(name: String, email: String, message: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_submit_contact_json(
|
|
FfiConverterString.lower(name),
|
|
FfiConverterString.lower(email),
|
|
FfiConverterString.lower(message),$0
|
|
)
|
|
})
|
|
}
|
|
public func submitContactV2Json(name: String, email: String, subject: String, message: String, phone: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_submit_contact_v2_json(
|
|
FfiConverterString.lower(name),
|
|
FfiConverterString.lower(email),
|
|
FfiConverterString.lower(subject),
|
|
FfiConverterString.lower(message),
|
|
FfiConverterString.lower(phone),$0
|
|
)
|
|
})
|
|
}
|
|
public func submitContactV2JsonLegacy(firstName: String, lastName: String, email: String, subject: String, message: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_submit_contact_v2_json_legacy(
|
|
FfiConverterString.lower(firstName),
|
|
FfiConverterString.lower(lastName),
|
|
FfiConverterString.lower(email),
|
|
FfiConverterString.lower(subject),
|
|
FfiConverterString.lower(message),$0
|
|
)
|
|
})
|
|
}
|
|
public func validateContactFormJson(formJson: String) -> String {
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_validate_contact_form_json(
|
|
FfiConverterString.lower(formJson),$0
|
|
)
|
|
})
|
|
}
|
|
public func validateEmailAddress(email: String) -> Bool {
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_validate_email_address(
|
|
FfiConverterString.lower(email),$0
|
|
)
|
|
})
|
|
}
|
|
public func validatePhoneNumber(phone: String) -> Bool {
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|
uniffi_church_core_fn_func_validate_phone_number(
|
|
FfiConverterString.lower(phone),$0
|
|
)
|
|
})
|
|
}
|
|
|
|
private enum InitializationResult {
|
|
case ok
|
|
case contractVersionMismatch
|
|
case apiChecksumMismatch
|
|
}
|
|
// Use a global variable to perform the versioning checks. Swift ensures that
|
|
// the code inside is only computed once.
|
|
private var initializationResult: InitializationResult = {
|
|
// Get the bindings contract version from our ComponentInterface
|
|
let bindings_contract_version = 26
|
|
// Get the scaffolding contract version by calling the into the dylib
|
|
let scaffolding_contract_version = ffi_church_core_uniffi_contract_version()
|
|
if bindings_contract_version != scaffolding_contract_version {
|
|
return InitializationResult.contractVersionMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_create_calendar_event_data() != 18038) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_create_sermon_share_items_json() != 7165) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_device_supports_av1() != 2798) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_extract_full_verse_text() != 33299) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_extract_scripture_references_string() != 54242) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_extract_stream_url_from_status() != 7333) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_bible_verse_json() != 62434) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_bulletins_json() != 51697) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_cached_image_base64() != 56508) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_config_json() != 22720) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_current_bulletin_json() != 15976) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_events_json() != 55699) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_featured_events_json() != 40496) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_live_stream_json() != 8362) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_livestream_archive_json() != 39665) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_random_bible_verse_json() != 24962) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_scripture_verses_for_sermon_json() != 54526) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_sermons_json() != 35127) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_fetch_stream_status_json() != 11864) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_filter_sermons_by_media_type() != 55463) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_format_event_for_display_json() != 9802) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_format_scripture_text_json() != 33940) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_format_time_range_string() != 30520) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_generate_home_feed_json() != 33935) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_generate_verse_description() != 57052) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_about_text() != 63404) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_av1_streaming_url() != 15580) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_brand_color() != 38100) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_church_address() != 9838) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_church_name() != 51038) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_contact_email() != 3208) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_contact_phone() != 48541) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_coordinates() != 64388) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_donation_url() != 24711) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_facebook_url() != 16208) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_hls_streaming_url() != 7230) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_instagram_url() != 24193) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_livestream_url() != 60946) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_media_type_display_name() != 34144) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_media_type_icon() != 5231) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_mission_statement() != 37182) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_optimal_streaming_url() != 37505) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_stream_live_status() != 5029) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_website_url() != 56118) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_get_youtube_url() != 37371) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_is_multi_day_event_check() != 59258) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_parse_bible_verse_from_json() != 56853) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_parse_bulletins_from_json() != 49597) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_parse_calendar_event_data() != 53928) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_parse_contact_result_from_json() != 10921) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_parse_events_from_json() != 6684) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_parse_sermons_from_json() != 46352) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_submit_contact_json() != 14960) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_submit_contact_v2_json() != 24485) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_submit_contact_v2_json_legacy() != 19210) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_validate_contact_form_json() != 44651) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_validate_email_address() != 14406) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
if (uniffi_church_core_checksum_func_validate_phone_number() != 58095) {
|
|
return InitializationResult.apiChecksumMismatch
|
|
}
|
|
|
|
return InitializationResult.ok
|
|
}()
|
|
|
|
private func uniffiEnsureInitialized() {
|
|
switch initializationResult {
|
|
case .ok:
|
|
break
|
|
case .contractVersionMismatch:
|
|
fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
|
case .apiChecksumMismatch:
|
|
fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
|
}
|
|
}
|
|
|
|
// swiftlint:enable all |