Skip to main content

azalea_chat/
lib.rs

1#![doc = include_str!("../README.md")]
2
3pub mod base_component;
4pub mod click_event;
5mod component;
6pub mod hover_event;
7#[cfg(feature = "numbers")]
8pub mod numbers;
9pub mod style;
10pub mod text_component;
11pub mod translatable_component;
12
13pub use component::{DEFAULT_STYLE, FormattedText};
14#[cfg(feature = "simdnbt")]
15use simdnbt::{DeserializeError, FromNbtTag};
16
17// TODO: remove this after simdnbt refactor
18#[cfg(feature = "simdnbt")]
19pub(crate) fn get_in_compound<T: FromNbtTag>(
20    compound: &simdnbt::borrow::NbtCompound,
21    key: &str,
22) -> Result<T, DeserializeError> {
23    let value = compound.get(key).ok_or(DeserializeError::MissingField)?;
24    T::from_nbt_tag(value).ok_or(DeserializeError::MissingField)
25}