Lifetime refactor & crate update#1
Conversation
DarkMrMelther
left a comment
There was a problem hiding this comment.
Hello! Thanks for the PR and the patience waiting till the review. The life time refactor seems great, good job, but we should move the MiniMessage integration into another PR, some changes should be made before adding MiniMsg format to the lib, talking specifically of your library, the constructor "minimessage" should be named "from_minimsg" since comes from another format, and should be placed in the minimsg crate, also to avoid having too many empty components we should have a final step that reorders components based on their styles or something similar, also to add the gradient tags we should add first the custom component types, and discuss with 4lve about server-side translations, since they are needed to add gradients for translated texts.
oka |
DarkMrMelther
left a comment
There was a problem hiding this comment.
It looks great now! LGTM! I will merge it into a dev branch since it could break Steel if merged into Master
This PR introduces lifetime annotations and ownership traits to the core component system, improving flexibility and enabling zero-copy deserialization where possible.
Added
RawTextComponent<'a>generic over the lifetime of borrowed data.ownablefeature withIntoOwnedandToOwnedderives for converting between borrowed and owned variants.databakefeature for bakeable (const-friendly) component structures.TextComponent = RawTextComponent<'static>preserving the previous API for owned use cases.Changed
TextComponent→RawTextComponent<'a>throughout the entire crate.Content,Format,Interactivity,TranslatedMessage,ClickEvent,HoverEvent,NbtSource,Object,ObjectPlayer,PlayerProperties,Resolvable) now carry a lifetime parameter.Modifier) andBuildTarget/TextResolutorto support lifetime‑aware components.build.rstranslation macro to generate constants compatible with the new API.Fixed
'static): the newTextComponentalias works exactly as before.Dependencies
ownable,databakeas optional dependencies.