Skip to content

0.1.49

Compare
Choose a tag to compare
@chinedufn chinedufn released this 09 Feb 12:28
· 63 commits to master since this release
d85c9b1
  • Support returning Result<OpaqueRust, OpaqueRust> from async Rust functions. #158 (thanks @NiwakaDev)

    // For example, the following is now possible:
    
    #[swift_bridge::bridge]
    mod ffi {
        extern "Rust" {
            type User;
            type ApiError;
    
            #[swift_bridge(swift_name = "loadUser")]
            async fn load_user() -> Result<User, ApiError>;
    
            fn print_info(self: &ApiError);
        }
    }
    // Swift
    
    do {
        let user = try await loadUser()
    } catch let err as ApiError {
        err.print_info()
    }
  • Introduce the #[swift_bridge(label = "...")] function argument attribute for generating Swift argument labels. #156 (thanks @NiwakaDev)

    // For example, the following is now possible:
    
    // Rust
    #[swift_bridge::bridge]
    mod ffi {
        extern "Rust" {
            fn add(
                #[swift_bridge(label = "leftHand")] 
                left_hand: i32,
                right_hand: i32,
            ) -> i32;
        }
    }
    
    fn add(left_hand: i32, right_hand: i32) -> i32 {
        left_hand + right_hand
    }
    // Swift
    
    let sum = add(leftHand: 10, 20)