Trait oc2_hlapi::device::RobotInterface
source · pub trait RobotInterface: RpcDevice {
Show 13 methods
// Required methods
fn get_energy_stored(&self) -> Result<i32>;
fn get_max_energy_stored(&self) -> Result<i32>;
fn get_selected_slot(&self) -> Result<i32>;
fn set_selected_slot(&self, slot: i32) -> Result<()>;
fn get_stack_in_slot<T: DeserializeOwned>(&self, slot: i32) -> Result<T>;
fn get_last_action_id(&self) -> Result<i32>;
fn get_queued_action_count(&self) -> Result<i32>;
fn get_action_result(&self, id: i32) -> Result<RobotActionResult>;
fn move_async(&self, direction: Direction) -> Result<()>;
fn turn_async(&self, direction: RotationDirection) -> Result<()>;
fn move_wait(&self, direction: Direction) -> Result<bool>;
fn turn_wait(&self, direction: RotationDirection) -> Result<bool>;
fn wait_for_action(&self, action: i32) -> Result<bool>;
}Expand description
An interface between robots and the HLAPI.
Required Methods§
sourcefn get_energy_stored(&self) -> Result<i32>
fn get_energy_stored(&self) -> Result<i32>
Returns the amount of FE stored in a robot.
sourcefn get_max_energy_stored(&self) -> Result<i32>
fn get_max_energy_stored(&self) -> Result<i32>
Returns the maximum possible energy that a robot can store.
sourcefn get_selected_slot(&self) -> Result<i32>
fn get_selected_slot(&self) -> Result<i32>
Returns the index of the currently active slot.
sourcefn set_selected_slot(&self, slot: i32) -> Result<()>
fn set_selected_slot(&self, slot: i32) -> Result<()>
Sets the currently active slot to the given index.
sourcefn get_stack_in_slot<T: DeserializeOwned>(&self, slot: i32) -> Result<T>
fn get_stack_in_slot<T: DeserializeOwned>(&self, slot: i32) -> Result<T>
Returns information about the item in the given slot.
sourcefn get_last_action_id(&self) -> Result<i32>
fn get_last_action_id(&self) -> Result<i32>
Returns the ID of the previously performed action.
sourcefn get_queued_action_count(&self) -> Result<i32>
fn get_queued_action_count(&self) -> Result<i32>
Returns the currently queued number of actions.
sourcefn get_action_result(&self, id: i32) -> Result<RobotActionResult>
fn get_action_result(&self, id: i32) -> Result<RobotActionResult>
Returns the state of a robot’s action with a given ID.
sourcefn move_async(&self, direction: Direction) -> Result<()>
fn move_async(&self, direction: Direction) -> Result<()>
Attempts to move in the given direction without blocking.
sourcefn turn_async(&self, direction: RotationDirection) -> Result<()>
fn turn_async(&self, direction: RotationDirection) -> Result<()>
Attempts to turn in the given direction without blocking.
sourcefn move_wait(&self, direction: Direction) -> Result<bool>
fn move_wait(&self, direction: Direction) -> Result<bool>
Attempts to move a robot in the given direction, blocking until the action has completed. Returns whether the operation completed successfully.
sourcefn turn_wait(&self, direction: RotationDirection) -> Result<bool>
fn turn_wait(&self, direction: RotationDirection) -> Result<bool>
Attempts to turn a robot in the given direction, blocking until the action has completed. Returns whether the operation completed successfully.
sourcefn wait_for_action(&self, action: i32) -> Result<bool>
fn wait_for_action(&self, action: i32) -> Result<bool>
Waits for the action with the given ID to complete. Returns whether the operation completed successfully.