Skip to content

Support calling async Swift throwing functions from Rust via Result<(), E> #348

Merged
chinedufn merged 34 commits into
chinedufn:masterfrom
Choochmeque:extern-swift-async-result-void
Dec 8, 2025
Merged

Support calling async Swift throwing functions from Rust via Result<(), E> #348
chinedufn merged 34 commits into
chinedufn:masterfrom
Choochmeque:extern-swift-async-result-void

Conversation

@Choochmeque

Copy link
Copy Markdown
Contributor
  • Add support for calling async Swift functions that throw errors from Rust and return void
  • Swift throwing functions are mapped to Rust Result<(), E> return type

Example

// rust
#[swift_bridge::bridge]
mod ffi {
    enum SwiftError {
        SomeError,
    }

    extern "Swift" {
        async fn swift_throwing_function_void(succeed: Bool) -> Result<(), SwiftError>;
    }
}
// swift
func swift_throwing_function_void(succeed: Bool) throws(SwiftError) {
    if !succeed {
        throw SwiftError.SomeError
    }
}

Choochmeque and others added 30 commits November 30, 2025 23:10
Choochmeque and others added 4 commits December 3, 2025 12:56
…wift-async-result-void

# Conflicts:
#	SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift
#	crates/swift-bridge-ir/src/codegen/codegen_tests/result.rs
#	crates/swift-bridge-ir/src/codegen/generate_swift.rs
@Choochmeque Choochmeque marked this pull request as ready for review December 5, 2025 12:38
@Choochmeque

Copy link
Copy Markdown
Contributor Author

Hi @chinedufn,
added support for Result<(), E> for async functions too, could you please review it when you have time?

@Choochmeque

Copy link
Copy Markdown
Contributor Author

@chinedufn, could you please review this PR as well?

@chinedufn chinedufn merged commit ee2b07d into chinedufn:master Dec 8, 2025
5 checks passed
chinedufn pushed a commit that referenced this pull request Dec 8, 2025
- Add support for calling async Swift functions that throw errors from Rust and return void
- Swift throwing functions are mapped to Rust Result<(), E> return type

## Example

```rust
// rust
#[swift_bridge::bridge]
mod ffi {
    enum SwiftError {
        SomeError,
    }

    extern "Swift" {
        async fn swift_throwing_function_void(succeed: Bool) -> Result<(), SwiftError>;
    }
}
```

```swift
// swift
func swift_throwing_function_void(succeed: Bool) throws(SwiftError) {
    if !succeed {
        throw SwiftError.SomeError
    }
}
```
@Choochmeque Choochmeque deleted the extern-swift-async-result-void branch December 8, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants