pub struct Locked<'invoker, 'buffer, B: Buffer> { /* private fields */ }
Expand description

An inventory controller component on which methods can be invoked.

This type combines an inventory controller address, an Invoker that can be used to make method calls, and a scratch buffer used to perform CBOR encoding and decoding. A value of this type can be created by calling Controller::lock, and it can be dropped to return the borrow of the invoker and buffer to the caller so they can be reused for other purposes.

Where a function is declared as taking impl Side, an AbsoluteSide must be passed if operating on a transposer or an upgrade module installed in an adapter, while a RelativeSide must be passed if operating on an upgrade module installed in a robot or drone.

The 'invoker lifetime is the lifetime of the invoker. The 'buffer lifetime is the lifetime of the buffer. The B type is the type of scratch buffer to use.

Implementations

Returns the number of slots in an inventory.

Errors

Returns the number of items in an inventory slot.

The slot parameter ranges from 1 to the inventory size.

Errors

Returns the maximum size of a stack of items, given the item in an inventory slot.

The slot parameter ranges from 1 to the inventory size. If the slot does not contain any items, None is returned because the maximum stack size depends on the item type.

Errors

Checks whether two inventory slots contain the same type of item.

The slot_a and slot_b parameters range from 1 to the inventory size. The check_nbt parameter indicates whether to consider NBT data attached to the item.

Two empty slots are considered equal. An empty slot and a populated slot are considered unequal. Two of the same item with different damage values are considered equal. Two stacks of different numbers of the same item are considered equal.

Errors

Checks whether two inventory slots contain ore-dictionary-equivalent items.

The slot_a and slot_b parameters range from 1 to the inventory size.

Two empty slots are considered equivalent. An empty slot and a populated slot are considered non-equivalent. A slot is considered equivalent to itself. Otherwise, two slots are considered equivalent if and only if the items in both slots have at least one ore dictionary “ore ID” entry in common.

Errors

Returns the item stack in an inventory slot.

The slot parameter ranges from 1 to the inventory size. If the slot does not contain any items, None is returned.

The strings in the returned item stack point into, and therefore retain ownership of, the scratch buffer. Consequently, the Locked is consumed and cannot be reused.

Errors

Returns a snapshot of all the item stacks in an inventory.

Errors

Returns the internal (Minecraft system) name of an inventory.

For example, this might be minecraft:chest.

The returned string points into, and therefore retains ownership of, the scratch buffer. Consequently, the Locked is consumed and cannot be reused.

Errors

Moves items between two inventories.

The count value indicates the maximum number of items to move. It is clamped to 64; even if a stack is larger than 64 items, no more than 64 can be moved in a single operation.

The transfer will only ever move items from one slot in the source inventory; the chosen slot is the first slot from which any items can actually be moved (that is, the first slot that is nonempty and at least one item of which fits in the sink). The transfer may place items into multiple slots in the sink; it first merges items into existing stacks of the same type, then, if any items are left to move, places them into empty slots, in both cases prioritizing based on the order of slots in the sink inventory. The number of items actually moved is returned.

Errors

Moves items between two inventories, taking from only a specific slot in the source.

The count value indicates the maximum number of items to move. It is clamped to 64; even if a stack is larger than 64 items, no more than 64 can be moved in a single operation.

The source_slot parameter ranges from 1 to the source inventory size.

The transfer may place items into multiple slots in the sink; it first merges items into existing stacks of the same type, then, if any items are left to move, places them into empty slots, in both cases prioritizing based on the order of slots in the sink inventory. The number of items actually moved is returned.

Errors

Moves items between two inventories, taking from only a specific slot in the source and storing to only a specific slot in the sink.

The count value indicates the maximum number of items to move. It is clamped to 64; even if a stack is larger than 64 items, no more than 64 can be moved in a single operation.

The source_slot parameter ranges from 1 to the source inventory size. The sink_slot parameter ranges from 1 to the sink inventory size.

Errors

Moves fluids between two tanks.

The count value indicates the maximum number of millibuckets to move. The number of millibuckets moved is returned.

If there is no fluid tank in one of the positions, or if one of the positions is in an unloaded chunk, Ok(0) is returned. OpenComputers does not consider this to be an error.

Errors

Returns the amount of fluid in a tank, in millibuckets.

The tank parameter ranges from 1 to the number of tanks in the target block.

Errors

Returns the amount of fluid a tank can hold, in millibuckets.

The tank parameter ranges from 1 to the number of tanks in the target block.

Errors

Returns the fluid in a tank.

The tank parameter ranges from 1 to the number of tanks in the target block.

Errors

Returns the fluids in all tanks in a block.

Although tanks are indexed starting from 1 in most situations, for the purpose of this method, the tanks are returned in a vector which is obviously 0-indexed.

Errors

Returns the amount of fluid in a fluid container in the robot or drone’s internal inventory.

The slot parameter ranges from 1 to the internal inventory size.

Errors

Returns the amount of fluid in the fluid container in the currently selected slot of the robot or drone’s internal inventory.

Errors

Returns the total size of a fluid container in the robot or drone’s internal inventory.

The slot parameter ranges from 1 to the internal inventory size.

Errors

Returns the total size of the fluid container in the currently selected slot of the robot or drone’s internal inventory.

If the slot does not contain a fluid container (either because it contains a non-fluid-container item or because it does not contain anything), None is returned.

Errors

Returns information about the fluid in a fluid container in the robot or drone’s internal inventory.

The slot parameter ranges from 1 to the internal inventory size.

If the slot contains an empty fluid container, None is returned.

Errors

Returns information about the fluid in the fluid container in the selected slot of the robot or drone’s internal inventory.

If the slot contains an empty fluid container, None is returned.

Errors

Returns information about the fluid in the robot or drone’s specified internal tank.

If the tank is empty, None is returned.

Errors

Returns information about the fluid in the robot or drone’s currently selected internal tank.

If the tank is empty, None is returned.

Errors

Moves fluid from a fluid container in the robot or drone’s currently selected inventory slot into the robot or drone’s currently selected internal tank.

On success, the amount of fluid moved is returned. For certain types of source containers, this may be larger than amount.

Errors
  • BadComponent
  • BadItem is returned if the item is not a fluid container, if there is no item in the selected slot, if there is no inventory, or in some cases if the item is empty.
  • Failed is returned in some cases if the item is empty.
  • InventoryFull
  • NoInventory is returned if there is no tank.

Moves fluid from the robot or drone’s currently selected internal tank into a fluid container in the robot or drone’s currently selected inventory slot.

On success, the amount of fluid moved is returned.

Errors
  • BadComponent
  • BadItem is returned if the item is not a fluid container, if there is no item in the selected slot, if there is no inventory, or in some cases if the item is full.
  • Failed is returned if the tank is empty, if the item contains a fluid that cannot be mixed with the fluid in the tank, or in some cases if the item is full.
  • NoInventory is returned if there is no tank.

Returns the item stack in a robot or drone’s internal inventory slot.

The slot parameter ranges from 1 to the inventory size. If the slot does not contain any items, None is returned.

The strings in the returned item stack point into, and therefore retain ownership of, the scratch buffer. Consequently, the Locked is consumed and cannot be reused.

Errors

Returns the item stack in the robot or drone’s currently selected internal inventory slot.

The strings in the returned item stack point into, and therefore retain ownership of, the scratch buffer. Consequently, the Locked is consumed and cannot be reused.

Errors

Checks whether a robot or drone’s internal inventory slot contains an ore-dictionary-equivalent item to the currently selected internal inventory slot.

The slot parameter ranges from 1 to the inventory size.

Two empty slots are considered equivalent. An empty slot and a populated slot are considered non-equivalent. A slot is considered equivalent to itself. Otherwise, two slots are considered equivalent if and only if the items in both slots have at least one ore dictionary “ore ID” entry in common.

Errors

Drops items from the robot’s selected slot into a specific slot of an adjacent inventory.

Up to count items from the currently selected slot in the robot’s inventory are moved into slot slot of the inventory on side side. The face parameter indicates which face of the destination location to look for inventory slots.

Errors

Sucks up items from a specific slot in an adjacent inventory block into the robot’s internal inventory.

Up to count items from the stack in slot slot in the inventory on side side are inserted into the robot’s inventory. The face parameter indicates on which face of the source location to look for inventory slots.

The sucked items are placed into the robot’s inventory, initially into the currently selected slot, then into slots after it, then wrapping around to slots before it, as necessary to hold all the sucked items. If there is not enough space to hold the items, then the items that cannot be held are left behind in their original location.

On success, the number of items actually moved is returned, which may be less than count if the source stack does not have that many items or if that many items do not fit into the robot’s inventory, including zero if the source stack is empty or there is no space at all in the robot.

Errors
  • BadComponent
  • Failed is returned if there is no inventory on side side (or on face face of the block on side side), or if slot is greater than the number of slots in the external inventory.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.