Comments (6)
Property wrappers and macro annotations should also accept parameters such that it would be possible to generate this example of the @SmallNumber
property wrapper defined in tutorial:
struct NarrowRectangle {
@SmallNumber(wrappedValue: 2, maximum: 5) var height: Int
@SmallNumber(wrappedValue: 3, maximum: 4) var width: Int
}
from uniffi-rs.
Also, I don't see much of a need for UniFFI to define Swift property wrappers or macros—it should only need to apply them. So if you attach e.g. #[uniffi::swift_macro(tasty(tastiness = 3))]
to a struct, it should take it on faith that the @tasty
macro already has a definition somewhere on the Swift side and then proceed to blindly apply the @tasty(tastiness: 3)
annotation to the generated Swift type. Done that way, UniFFI can remain reasonably decoupled from the Swift release cycle in terms of property wrappers and macros, and UniFFI can apply any property wrapper or macro that exists anywhere on the Swift side.
from uniffi-rs.
That sounds great, but difficult to express in UniFFI's model. Happy to help if you want to have a start at this though.
from uniffi-rs.
@mhammond Thanks! Turns out there's already a convention for writing SwiftUI code with UniFFI, and it's a lot less complicated and more sustainable than this feature would be 😄 Thanks for humoring my whim. Closing as not planned.
from uniffi-rs.
@cadnza What is the convention for writing SwiftUI code with UniFFI with regard to having a view update when a field in a UniFFi Interface / rust struct changes?
from uniffi-rs.
@cadnza What is the convention for writing SwiftUI code with UniFFI with regard to having a view update when a field in a UniFFi Interface / rust struct changes?
@GraniteLake As far as I understand—first pointing out how wide and varied my lack of experience is with this—the way it's usually done is by writing an intermediary stuct/class in Swift that wraps UniFFI's class and adds SwiftUI's property wrappers and macro annotations. As far as how you get UniFFI to update the struct based on those wrappers and annotations, I'm not sure, but something along those lines is what I've been seeing going through other peoples' code.
from uniffi-rs.
Related Issues (20)
- Generating FFI bindings for dependent crates into one single Swift / Kotlin file? HOT 4
- External type fails for some corner cases HOT 1
- Config feature and Export macros don't get along HOT 1
- iOS Framework Expected in: /usr/lib/libc++.1.dylib HOT 3
- Remote interface types
- Updating from 0.25.3 to 0.26.x or 0.27.x fails for interface HOT 8
- Java 8 deprecation is unexpected
- #[doc = ...] fails to parse with uniffi attribute macros HOT 3
- update docs/diplomat-and-macros.md
- Crates.io shows 0.27.2 but the associated tag doesn't exist HOT 3
- Advice on creating external bindings for a comment type system only HOT 3
- Question: Convention for using UniFFI with SwiftUI (Update a SwiftUI view when a UniFFI interface object changes). HOT 5
- Some old docs 404s HOT 1
- How to share a reference to a struct with UniFFI? HOT 3
- Support for `Option<&T>`
- Support for projects not using `cargo`
- Workspace broken | UniFFI generates invalid Swift & Python bindings HOT 4
- Design and agree on a 1.0 FFI HOT 1
- Use C structs/tagged unions for Records/Enums HOT 1
- Store return values in RustCallStatus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uniffi-rs.