Trait PlaceProvider
pub trait PlaceProvider:
Send
+ Sync
+ 'static {
// Required methods
fn stack(&self, host: &mut dyn ServerHost, key: u64) -> Option<ItemStack>;
fn insert(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
key: u64,
resource: &ItemResource,
amount: u32,
) -> u32;
fn extract(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
key: u64,
resource: &ItemResource,
amount: u32,
) -> u32;
}Expand description
A mod’s own places (ItemPlace::Mod), registered with
Registrar::place_provider: NeoForge’s own ItemAccesss.
Like a handler, it holds no borrow: its stacks live where the mod keeps them (a player’s
attachments). While its mod is disabled, lookups refuse both reads and writes through its
places; re-enabling the mod makes the same registrations available again.
Required Methods§
fn stack(&self, host: &mut dyn ServerHost, key: u64) -> Option<ItemStack>
fn stack(&self, host: &mut dyn ServerHost, key: u64) -> Option<ItemStack>
The stack at key, if any.
fn insert(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
key: u64,
resource: &ItemResource,
amount: u32,
) -> u32
fn insert( &self, host: &mut dyn ServerHost, tx: &Transaction, key: u64, resource: &ItemResource, amount: u32, ) -> u32
Puts up to amount of resource at key, in transaction tx: how much went. What
doesn’t stack with what is there may go where the mod puts it, such as the player’s
inventory (ItemAccess.insert); none where key is no longer a place.
fn extract(
&self,
host: &mut dyn ServerHost,
tx: &Transaction,
key: u64,
resource: &ItemResource,
amount: u32,
) -> u32
fn extract( &self, host: &mut dyn ServerHost, tx: &Transaction, key: u64, resource: &ItemResource, amount: u32, ) -> u32
Takes up to amount of resource from key, in transaction tx: how much came.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".