pub struct ContainerRef {
id: ContainerId,
source: SharedContainer,
owner: Option<Arc<BlockEntityBase>>,
}Expand description
A reference to a container that can be locked.
The optional owner is notified only after all container locks have been
released at the corresponding Vanilla setChanged boundary.
Fields§
§id: ContainerId§source: SharedContainer§owner: Option<Arc<BlockEntityBase>>Implementations§
Source§impl ContainerRef
impl ContainerRef
Sourcepub fn from_block_entity(block_entity: SharedBlockEntity) -> Option<Self>
pub fn from_block_entity(block_entity: SharedBlockEntity) -> Option<Self>
Creates a ContainerRef from a block entity, if it implements Container.
Returns None if the block entity has no container capability.
Sourcepub fn owned_by_block_entity(
container: SharedContainer,
owner: Arc<BlockEntityBase>,
) -> Self
pub fn owned_by_block_entity( container: SharedContainer, owner: Arc<BlockEntityBase>, ) -> Self
Creates a container capability owned by the block entity whose unique
base is returned from its crate::block_entity::BlockEntity::base.
The container implementation must obey Container’s storage-local
locking contract. This owner performs block-entity and comparator
notifications after all container locks are released.
Sourcepub const fn container_id(&self) -> ContainerId
pub const fn container_id(&self) -> ContainerId
Returns a unique identifier for this container based on its Arc pointer address.
Sourcepub fn still_valid(&self, player: &Player) -> bool
pub fn still_valid(&self, player: &Player) -> bool
Checks container access without locking its item storage.
Sourcefn lock(&self) -> LockedContainer
fn lock(&self) -> LockedContainer
Locks this container and returns a guard.
Trait Implementations§
Source§impl Clone for ContainerRef
impl Clone for ContainerRef
Source§fn clone(&self) -> ContainerRef
fn clone(&self) -> ContainerRef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl From<&Arc<Mutex<RawMutex, dyn Container>>> for ContainerRef
impl From<&Arc<Mutex<RawMutex, dyn Container>>> for ContainerRef
Source§fn from(container: &SharedContainer) -> Self
fn from(container: &SharedContainer) -> Self
Source§impl From<&ContainerRef> for ContainerRef
impl From<&ContainerRef> for ContainerRef
Source§fn from(r: &ContainerRef) -> Self
fn from(r: &ContainerRef) -> Self
Source§impl From<Arc<Mutex<RawMutex, dyn Container>>> for ContainerRef
impl From<Arc<Mutex<RawMutex, dyn Container>>> for ContainerRef
Source§fn from(container: SharedContainer) -> Self
fn from(container: SharedContainer) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for ContainerRef
impl !UnwindSafe for ContainerRef
impl Freeze for ContainerRef
impl Send for ContainerRef
impl Sync for ContainerRef
impl Unpin for ContainerRef
impl UnsafeUnpin for ContainerRef
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<>>