Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[target.aarch64-linux-android]
linker = "/opt/homebrew/share/android-commandlinetools/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android30-clang"
ar = "/opt/homebrew/share/android-commandlinetools/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"

[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-ar"

[env]
# Set Android SDK/NDK paths
ANDROID_NDK_HOME = "/opt/homebrew/share/android-commandlinetools/ndk/28.2.13676358"
ANDROID_NDK_ROOT = "/opt/homebrew/share/android-commandlinetools/ndk/28.2.13676358"
37 changes: 36 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,36 @@ env_logger = "0.11.8"
once_cell = "1.21.3"

# Optional dependencies for specific transports
quinn = { version = "0.11.8", optional = true }
quinn = { version = "0.11.8", optional = true, default-features = false, features = ["rustls-ring"] }
tokio-rustls = { version = "0.26.2", optional = true }
webrtc = { version = "0.13.0", optional = true }
libc = "0.2"

# Platform-specific dependencies for path monitoring
[target.'cfg(target_vendor = "apple")'.dependencies]
libc = "0.2"

[target.'cfg(target_os = "linux")'.dependencies]
rtnetlink = "0.14"
netlink-packet-route = "0.19"
futures = "0.3"

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.58", features = [
"Win32_NetworkManagement_IpHelper",
"Win32_NetworkManagement_Ndis",
"Win32_Foundation",
"Win32_Networking_WinSock",
] }

[target.'cfg(target_os = "android")'.dependencies]
jni = "0.21"

[dev-dependencies]
tokio-test = "0.4.4"
env_logger = "0.11.8"
ctrlc = "3.4"
chrono = "0.4"

[build-dependencies]
cbindgen = { version = "0.29.0", optional = true }
Expand All @@ -48,3 +71,15 @@ cbindgen = ["dep:cbindgen"]
lto = true
codegen-units = 1
opt-level = 3

[[example]]
name = "path_monitor"
required-features = []

[[example]]
name = "path_monitor_detailed"
required-features = []

[[example]]
name = "path_monitor_watch"
required-features = []
10 changes: 2 additions & 8 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,12 @@ RUN mkdir -p /opt && \
mv android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME} && \
rm android-ndk.zip

# Install Rust targets
# Install Rust targets (only those available in stable Rust)
RUN rustup target add \
aarch64-apple-ios \
aarch64-apple-tvos \
aarch64-apple-darwin \
x86_64-apple-darwin \
aarch64-apple-watchos \
aarch64-linux-android \
x86_64-unknown-linux-gnu \
aarch64-unknown-linux-gnu \
x86_64-pc-windows-gnu \
aarch64-pc-windows-gnullvm
x86_64-pc-windows-gnu

# Install cbindgen
RUN cargo install cbindgen
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:6.2
// swift-tools-version:6.1
import PackageDescription
#if canImport(FoundationEssentials)
import FoundationEssentials // Needed for binary target support
Expand Down
44 changes: 39 additions & 5 deletions bindings/swift/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Transport Services Swift Bindings

Swift bindings for the Transport Services (RFC 9622) implementation.
Modern Swift 6 bindings for the Transport Services (RFC 9622) implementation with full concurrency support.

## Overview

This package provides a Swift-friendly API for Transport Services, wrapping the underlying Rust FFI implementation.
This package provides a Swift-friendly API for Transport Services, wrapping the underlying Rust FFI implementation with modern Swift concurrency features including async/await, AsyncSequence, and Sendable conformance.

## Building

Expand All @@ -26,6 +26,8 @@ USE_LOCAL_ARTIFACT=1 swift test

## Usage

### Basic Connection Example

```swift
import TransportServices

Expand Down Expand Up @@ -55,6 +57,35 @@ try await connection.close()
TransportServices.cleanup()
```

### Path Monitoring Example

```swift
import TransportServices

// Create a path monitor
let monitor = try PathMonitor()

// List current interfaces
let interfaces = try await monitor.interfaces()
for interface in interfaces {
print("\(interface.name): \(interface.status) - \(interface.interfaceType)")
}

// Monitor network changes
for await event in monitor.changes() {
switch event {
case .added(let interface):
print("Interface added: \(interface.name)")
case .removed(let interface):
print("Interface removed: \(interface.name)")
case .modified(let old, let new):
print("Interface changed: \(new.name)")
case .pathChanged(let description):
print("Path changed: \(description)")
}
}
```

## Requirements

- Swift 6.2 or later
Expand All @@ -65,9 +96,12 @@ TransportServices.cleanup()
- [x] Basic package structure
- [x] FFI binary target integration
- [x] Swift Testing setup
- [ ] Complete async/await wrappers
- [x] Path monitoring with async/await
- [x] NetworkInterface type with Sendable conformance
- [x] AsyncSequence for network changes
- [x] Thread-safe actor-based implementation
- [ ] Complete connection async/await wrappers
- [ ] Endpoint implementations
- [ ] Transport properties
- [ ] Security parameters
- [ ] Event handling
- [ ] Error handling
- [ ] Connection event handling
Loading
Loading