another.im-ios/rust/monal-rust-swift-bridge/swift/panichandling.swift

12 lines
430 B
Swift
Raw Normal View History

2024-11-18 14:53:52 +00:00
public typealias rust_panic_handler_t = @convention(block) (String, String) -> Void;
var panicHandler: Optional<rust_panic_handler_t> = nil;
public func setRustPanicHandler(_ ph: @escaping rust_panic_handler_t) {
panicHandler = ph;
install_panichandler();
}
public func rust_panic_handler(text: RustString, backtrace: RustString) {
if let ph = panicHandler {
ph(text.toString(), backtrace.toString());
}
}