#[non_exhaustive]pub enum SectionKind {
Normal,
Restricted(Arc<RestrictedRules>),
Display,
Custom(SlotFactory),
}Expand description
How a section lowers container indices into menu slots.
The section methods pick the indices; the kind decides what each index
becomes. Accepted by MenuBuilder::section_with, MenuBuilder::section_at,
MenuBuilder::player_inventory_with and grid placements via
PlacementBuilder::kind.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Normal
Plain storage slots.
Restricted(Arc<RestrictedRules>)
Placement gated by the rules; pickup gated too when they carry a pickup
predicate. Built by restricted,
guarded and take_only.
Display
No placement, no pickup; clicks are rejected and surface in
MenuKind::on_slot_clicked.
Custom(SlotFactory)
Slots produced by a caller-supplied factory.
Implementations§
Source§impl SectionKind
impl SectionKind
Sourcepub fn restricted(
may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static,
) -> Self
pub fn restricted( may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static, ) -> Self
Placement gated by may_place, which receives the container-local slot
index; pickup stays allowed.
Sourcepub fn guarded(
may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static,
may_pickup: impl Fn(usize, &ItemStack, &ContainerLockGuard, &Player) -> bool + Send + Sync + 'static,
) -> Self
pub fn guarded( may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static, may_pickup: impl Fn(usize, &ItemStack, &ContainerLockGuard, &Player) -> bool + Send + Sync + 'static, ) -> Self
Like restricted, but pickup is also gated: items
only come out while may_pickup returns true.
Sourcepub fn custom(
factory: impl Fn(&ContainerRef, usize) -> Box<dyn Slot> + Send + Sync + 'static,
) -> Self
pub fn custom( factory: impl Fn(&ContainerRef, usize) -> Box<dyn Slot> + Send + Sync + 'static, ) -> Self
Slots produced by factory from the section’s container and each
covered container index.
Sourcepub fn take_only() -> Self
pub fn take_only() -> Self
Pickup allowed, placement always rejected — take-only output-style slots.
pub(crate) fn make( &self, container: &ContainerRef, index: usize, ) -> Box<dyn Slot>
Trait Implementations§
Source§impl Clone for SectionKind
impl Clone for SectionKind
Source§fn clone(&self) -> SectionKind
fn clone(&self) -> SectionKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SectionKind
impl Debug for SectionKind
Source§impl From<&SectionKind> for SectionKind
impl From<&SectionKind> for SectionKind
Auto Trait Implementations§
impl !RefUnwindSafe for SectionKind
impl !UnwindSafe for SectionKind
impl Freeze for SectionKind
impl Send for SectionKind
impl Sync for SectionKind
impl Unpin for SectionKind
impl UnsafeUnpin for SectionKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>