Struct MmsApi

Source
pub struct MmsApi;
Expand description

The main wrapper around the mms api. Holds locks to stdin and stdout to allow for fast and exclusive access for the api.

Implementations§

Source§

impl MmsApi

Source

pub fn maze_width() -> i32

Returns the width of the maze

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn maze_height() -> i32

Returns the height of the maze

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn wall_front() -> bool

Returns true if there is a wall in front of the robot, else false

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn wall_right() -> bool

Returns true if there is a wall to the right of the robot, else false

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn wall_left() -> bool

Returns true if there is a wall to the left of the robot, else false

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn move_forward(distance: Option<NonZeroU32>)

Move the robot forward the specified number of cells

Args:

  • distance: The optional non-zero number of cells to move forward. Default = 1
§Errors

IoError ParseIntError ParseFloatError InvalidAck

§Panics

this panics when use_panics is disabled

Source

pub fn turn_right()

Turn the robot ninety degrees to the right

§Errors

IoError ParseIntError ParseFloatError InvalidAck

§Panics

this panics when use_panics is disabled

Source

pub fn turn_left()

Turn the robot ninety degrees to the left

§Errors

IoError ParseIntError ParseFloatError InvalidAck

§Panics

this panics when use_panics is disabled

Source

pub fn set_wall(x: u32, y: u32, direction: &Direction)

Display a wall at the given position

Args:

  • x: The X coordinate of the cell
  • y: The Y coordinate of the cell
  • direction: The direction of the wall
§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn clear_wall(x: u32, y: u32, direction: &Direction)

Clear the wall at the given position

Args:

  • x: The X coordinate of the cell
  • y: The Y coordinate of the cell
  • direction: The direction of the wall
§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn set_color(x: u32, y: u32, color: &CellColor)

Set the color of the cell at the given position

Args:

  • x: The X coordinate of the cell
  • y: The Y coordinate of the cell
  • color: The color of the cell
§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn clear_color(x: u32, y: u32)

Clear the color of the cell at the given position

Args:

  • x: The X coordinate of the cell
  • y: The Y coordinate of the cell
§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn clear_all_color()

Clear the color of all cells

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn set_text(x: u32, y: u32, text: &str)

Set the text of the cell at the given position

Args:

  • x: The X coordinate of the cell
  • y: The Y coordinate of the cell
  • text: The desired text, max length 10
§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn clear_text(x: u32, y: u32)

Clear the text of the cell at the given position

Args:

  • x: The X coordinate of the cell
  • y: The Y coordinate of the cell
§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn clear_all_text()

Clear the text of all cells

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn was_reset() -> bool

Returns true if the reset button was pressed, else false

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Source

pub fn ack_reset()

Allow the mouse to be moved back to the start of the maze

§Errors

IoError ParseIntError ParseFloatError InvalidAck

§Panics

this panics when use_panics is disabled

Source

pub fn get_stat(query: &StatQuery) -> Stat

The value of the stat, or -1 if no value exists yet.

§Errors

IoError ParseIntError ParseFloatError

§Panics

this panics when use_panics is disabled

Auto Trait Implementations§

§

impl Freeze for MmsApi

§

impl RefUnwindSafe for MmsApi

§

impl Send for MmsApi

§

impl Sync for MmsApi

§

impl Unpin for MmsApi

§

impl UnwindSafe for MmsApi

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.