SingleEntityCodec

Trait SingleEntityCodec 

Source
pub trait SingleEntityCodec {
    type Comp: Default + Component;

    // Required methods
    fn encode(&self, src: &Self::Comp, dst: &mut CompoundTag);
    fn decode(&self, src: &CompoundTag) -> Self::Comp;
}
Expand description

This trait is a simpler specification of EntityCodec with the restriction of allowing only one component (implementing hecs::Component) to be encoded or decoded. The component type also have to implement Default to provide a default EntityCodec::default implementation.

Implementing this trait automatically means that you are implementing EntityCodec on Self, with encode, decode and default automatically defined to delegate to this trait.

Required Associated Types§

Source

type Comp: Default + Component

Component type, an associated type is used to allow only on implementation per codec struct.

Required Methods§

Source

fn encode(&self, src: &Self::Comp, dst: &mut CompoundTag)

Source

fn decode(&self, src: &CompoundTag) -> Self::Comp

Implementors§