Expand description
Swift language exporter for Specta.
This crate provides functionality to export Rust types to Swift code.
§Usage
Add specta, specta-serde, and specta-swift to your project:
cargo add specta@2.0.0-rc.25 --features derive,collect
cargo add specta-serde@0.0.12
cargo add specta-swift@0.0.3Next copy the following into your main.rs file:
use specta::{Type, Types};
use specta_swift::Swift;
#[derive(Type)]
pub struct MyType {
pub field: MyOtherType,
}
#[derive(Type)]
pub struct MyOtherType {
pub other_field: String,
}
let types = Types::default()
// We don't need to specify `MyOtherType` because it's referenced by `MyType`
.register::<MyType>();
Swift::default()
.export_to("./Types.swift", &types, specta_serde::Format)
.unwrap();Now you’re set up with Specta Swift!
If you get tired of listing all your types, checkout [specta::collect].
Structs§
- Swift
- Swift language exporter.
Enums§
- Error
- Errors that can occur during Swift code generation.
- Generic
Style - Generic type style for Swift.
- Indent
Style - Indentation style for generated Swift code.
- Naming
Convention - Naming convention for Swift identifiers.
- Optional
Style - Optional type style for Swift.