swift_runtime/string.rs
1//! Swift string creation from Rust.
2
3/// Create a Swift small string (≤15 bytes) as raw bytes.
4pub fn create_small(s: &str) -> Option<[u8; 16]> {
5 swift_runtime_sys::StdlibTypes::create_swift_string(s)
6}
7
8/// Extract the contents of a Swift small string.
9pub fn extract_small(buf: &[u8; 16]) -> Option<&str> {
10 swift_runtime_sys::StdlibTypes::extract_small_string(buf)
11}
12
13/// Create a Swift.String via the runtime (supports any length).
14///
15/// Returns the 16-byte String representation.
16pub fn create(s: &str) -> Option<[u8; 16]> {
17 unsafe { swift_runtime_sys::SwiftUIBridge::create_swift_string(s).ok() }
18}