pub trait EntityEquipment: Send {
// Required methods
fn get_ref(&self, slot: EquipmentSlot) -> &ItemStack;
fn get_mut(&mut self, slot: EquipmentSlot) -> &mut ItemStack;
fn set(&mut self, slot: EquipmentSlot, stack: ItemStack) -> ItemStack;
fn take(&mut self, slot: EquipmentSlot) -> ItemStack;
fn clear(&mut self);
// Provided method
fn non_empty_items(&self) -> Vec<(EquipmentSlot, ItemStack)> { ... }
}Expand description
Equipment access shared by player inventories and owned entity storage.
Required Methods§
Sourcefn get_ref(&self, slot: EquipmentSlot) -> &ItemStack
fn get_ref(&self, slot: EquipmentSlot) -> &ItemStack
Gets a reference to the item in a slot.
Sourcefn get_mut(&mut self, slot: EquipmentSlot) -> &mut ItemStack
fn get_mut(&mut self, slot: EquipmentSlot) -> &mut ItemStack
Gets a mutable reference to the item in a slot.
Sourcefn set(&mut self, slot: EquipmentSlot, stack: ItemStack) -> ItemStack
fn set(&mut self, slot: EquipmentSlot, stack: ItemStack) -> ItemStack
Sets the item in a slot, returning the old item.
Sourcefn take(&mut self, slot: EquipmentSlot) -> ItemStack
fn take(&mut self, slot: EquipmentSlot) -> ItemStack
Takes the item from a slot, leaving an empty stack in its place.
Provided Methods§
Sourcefn non_empty_items(&self) -> Vec<(EquipmentSlot, ItemStack)>
fn non_empty_items(&self) -> Vec<(EquipmentSlot, ItemStack)>
Returns non-empty equipment slots for initial spawn synchronization.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".