pub trait ResultHandler: Send + Sync {
// Required methods
fn result_container(&self) -> ContainerRef;
fn dependencies(&self) -> Vec<ContainerRef>;
fn update_result(&self, guard: &mut ContainerLockGuard);
fn on_result_taken(
&self,
guard: &mut ContainerLockGuard,
player: &Player,
) -> Option<ItemStack>;
fn is_result_valid(
&self,
guard: &ContainerLockGuard,
player: &Player,
) -> bool;
}Expand description
A trait for recipe handlers that update slots in containers according to recipes
Required Methods§
Sourcefn result_container(&self) -> ContainerRef
fn result_container(&self) -> ContainerRef
The container the result is written to and read from.
ResultSlot::new derives the
slot’s container from this. Menu builders reuse that exact reference for
validation and locking, so handler writes and slot reads cannot target
different containers.
Sourcefn dependencies(&self) -> Vec<ContainerRef>
fn dependencies(&self) -> Vec<ContainerRef>
Auxiliary containers accessed while validating or taking the result.
The result container itself is already supplied by
result_container and must not be repeated.
Sourcefn update_result(&self, guard: &mut ContainerLockGuard)
fn update_result(&self, guard: &mut ContainerLockGuard)
Recalculate the result based on current inputs.
Sourcefn on_result_taken(
&self,
guard: &mut ContainerLockGuard,
player: &Player,
) -> Option<ItemStack>
fn on_result_taken( &self, guard: &mut ContainerLockGuard, player: &Player, ) -> Option<ItemStack>
Consume inputs when the result is taken. Return overflow remainders.
Sourcefn is_result_valid(&self, guard: &ContainerLockGuard, player: &Player) -> bool
fn is_result_valid(&self, guard: &ContainerLockGuard, player: &Player) -> bool
Whether the stored result still matches the current inputs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".