Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specta-impls crate #185

Closed
wants to merge 5 commits into from
Closed

specta-impls crate #185

wants to merge 5 commits into from

Conversation

oscartbeaumont
Copy link
Member

@oscartbeaumont oscartbeaumont commented Nov 25, 2023

This code is cursed but I think it's the way.

I want Specta v2 to be able to develop an ecosystem.

That means independent crates implementing specta::Type instead of it being on specta to do it for them.

If specta maintains the impls for downstream crates if any of the downstream crates have a major version bump specta either has to also do a major release or introduce a new feature Eg. tauri, tauri2, etc.

Specta doing a major release is not a viable option because every downstream crate that has provided a Specta implementation will also need to be upgraded. Hence downstream maintainers don't wanna take on crates that are gonna commonly have major version bumps. This whole thing is also bad for everyone using the libraries because if the versions mismatch between different libraries your using you are just outta luck.

By introducing a specta-impls crate, and some cursed code to avoid the orphan rule we can allow specta-impls to do major releases without breaking

This allows me to decouple major versions of the Specta features for other crates from the Specta core traits.

@oscartbeaumont
Copy link
Member Author

Should also add a specta_core crate for the traits cause they hopefully won't change every once I am happy with them. Mostly just gonna refine the generics bit.

@appinteractive
Copy link

any update on that one?

@oscartbeaumont
Copy link
Member Author

Not at the moment. None of this should matter much to an end-user of Specta though.

For now, you can use the features on the Specta crate itself or if you own a downstream crate implement Type within it.

@oscartbeaumont
Copy link
Member Author

I'm closing this as I am very certain it's not the correct way to achieve the objective.

Due to how Cargo's semver works we can make downstream crates depend on 2.0.0-rc.x and they will automatically "upgrade" to 2.x.x as they are a semver match. This means as long as we implement the trait using the macro the only things that can't change are:

  • specta::Type export
  • Any #[specta(...)] attribute being used.

We are using this method with tauri right now but I will follow up with the rest of the implementation before we launch Specta v2 as stable.

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