Skip to content

Conversation

@hasezoey
Copy link
Contributor

@hasezoey hasezoey commented Oct 17, 2025

ISSUE NUMBER - PULL_REQUEST_TITLE

None

Description

I had found that the current MockComponent attr and query are quite limited in what data they can give out and receive, only being limited to AttrValue, PropPayload and PropValue variants.
The new PropPayload::Any makes use of rust dyn Any for being able to store arbitrary data, later being able to downcast to the wanted value.

Sadly the implementation is not quite as clean as i wanted it to be, requiring multiple traits working together and for super-trait casting (getting access to trait Any functions from PropBound or other traits).
Due to the bound on PropPayload requiring Clone and in std there not being a good dyn Clone and manually implementing it would be even more messy than PartialEq, i chose to use the package dyn-clone and manually implement dyn PartialEq, with the limitation of only comparing the same type (ie String("Hello") == String("Hello") == true, but this does not allow String("Hello") == str("Hello") == false). This limitation could be resolved somewhat using a additional bound like Borrow, but i dont know how useful this would be here.

I also added a new example showcasing making use of this new PropPayload::Any.

In the future, this could allow moving things like ::props::dataset into the place they likely should actually be in, which would be tuirealm-std::Chart and removing some extra variants in PropPayload / PropValue.

Type of change

Please select relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the contribution guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I formatted the code with cargo fmt
  • I checked my code using cargo clippy and reports no warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have introduced no new C-bindings
  • The changes I've made are Windows, MacOS, UNIX, Linux compatible (or I've handled them using cfg target_os)
  • I increased or maintained the code coverage for the project, compared to the previous commit

PS: this is marked as a DRAFT for feedback before saying it is ready ... treat it basically as a ready Proof-Of-Concept for now.

@cocogitto-bot
Copy link

cocogitto-bot bot commented Oct 17, 2025

✔️ f9c796a...6a245bf - Conventional commits check succeeded.

@hasezoey
Copy link
Contributor Author

I just noticed, should i also add a ::Any variant to State?

@veeso
Copy link
Owner

veeso commented Nov 10, 2025

Great job! Yes, probably it would make sense to implement this for state too.

@hasezoey hasezoey changed the title Add PropPayload::Any for arbitrary data exchange Add PropPayload::Any & State::Any for arbitrary data exchange Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants