swift-runtime 0.0.2

Safe Rust interface to the Swift Runtime
Documentation
  • Coverage
  • 92.16%
    47 out of 51 items documented0 out of 39 items with examples
  • Size
  • Source code size: 24.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.4 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 20s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • eugenehp/rswift
    9 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • eugenehp

swift-runtime

A safe Rust interface to the Swift runtime, over swift-runtime-sys: metadata lookup and inspection, reference counting, dynamic casts and type names, with the pointer arithmetic and the lifetime rules kept on this side of the boundary.

use swift_runtime::metadata::Metadata;

// `from_raw` rejects null, and everything after it is safe: the kind, the size
// and stride, and whether the type is POD all come from the value witness table.
if let Some(m) = Metadata::from_raw(raw) {
    println!("{:?} — {} bytes, stride {}", m.kind(), m.size(), m.stride());
}

swiftui-native is what this was built for: SwiftUI driven entirely from Rust.

Requirements

  • arm64 macOS or iOS. The Swift 6.3+ runtime ships with the OS.
  • Rust 1.82 or newer.

Licence

GPL-3.0. See the repository.