Struct Text
#[non_exhaustive]pub struct Text {
pub content: TextContent,
pub style: TextStyle,
pub children: Vec<Text>,
pub metadata: Tag,
}Expand description
A component tree, retaining translation keys, styles and ordered children.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.content: TextContentThe component’s contents before its children.
style: TextStyleFields not set here inherit from the enclosing component.
children: Vec<Text>Components appended in order.
metadata: TagUnrecognised component metadata survives an engine round trip, as a compound.
Implementations§
§impl Text
impl Text
pub fn new(content: TextContent) -> Text
pub fn new(content: TextContent) -> Text
A component with the given contents, with no style overrides or children.
pub fn validate_depth(&self) -> Result<(), TextFormError>
pub fn validate_depth(&self) -> Result<(), TextFormError>
Check vanilla’s component-depth bound before cloning any node payload. Counts every recursive component relation, including hover names.
pub fn literal(value: impl Into<String>) -> Text
pub fn literal(value: impl Into<String>) -> Text
A literal component, with no inherited style overrides or children.
pub fn translate(key: impl Into<String>, arguments: Vec<Text>) -> Text
pub fn translate(key: impl Into<String>, arguments: Vec<Text>) -> Text
A translatable component. The key and arguments remain unresolved data.
pub fn with_style(self, style: TextStyle) -> Text
pub fn with_style(self, style: TextStyle) -> Text
Set this component’s style; children continue to inherit unset fields.
§impl Text
impl Text
pub fn validate(&self) -> Result<(), TextFormError>
pub fn validate(&self) -> Result<(), TextFormError>
Validate component paths, opaque NBT containers and typed profile fields before constructing owned conversion payloads. This does not impose JSON representation restrictions on NBT data; engine emission may refuse those.
pub fn visit_children<'a>(&'a self, visit: impl FnMut(&'a Text, TextRelation))
pub fn visit_children<'a>(&'a self, visit: impl FnMut(&'a Text, TextRelation))
Visit recursive component slots in their relation order, without cloning. Opaque NBT data is not a component edge.