Space

Trait Space 

Source
pub trait Space<W, C, O>
where C: BasicCell, W: BasicWorld<C>, O: OutputField<C, Self::CellRepr>,
{ type CellRepr; type Reprer: Fn(C) -> Self::CellRepr; // Required methods fn world_mut(&mut self) -> &mut W; fn world(&self) -> &W; fn output_mut(&mut self) -> &mut O; fn reprer(&self) -> Self::Reprer; // Provided methods fn draw_whole(&mut self) -> Result<(), String> { ... } fn draw_delta(&mut self) -> Result<(), String> { ... } fn tick_whole(&mut self) -> Result<(), String> { ... } fn tick_delta(&mut self) -> Result<(), String> { ... } fn replace_with_random_world(&mut self) -> Result<(), String> { ... } fn replace_with_blank_world(&mut self) -> Result<(), String> { ... } fn click_world(&mut self, i: Index) { ... } }
Expand description

A Space (like a Gui) where a BasicWorld can show its BasicCells It only cares about learning how to lay the cells in the world

Required Associated Types§

Source

type CellRepr

The Space’s reprsentation of the BasicCells in the OutputField

Source

type Reprer: Fn(C) -> Self::CellRepr

A pure Fn that takes a BasicCell and returns that its representation

Required Methods§

Source

fn world_mut(&mut self) -> &mut W

Get a mutable reference to the BasicWorld the Space manages

Source

fn world(&self) -> &W

Get a shared reference to the BasicWorld the Space manages

Source

fn output_mut(&mut self) -> &mut O

Get a mutable referene to the OutputField of this Space

Source

fn reprer(&self) -> Self::Reprer

Get the representer of the Space

Provided Methods§

Source

fn draw_whole(&mut self) -> Result<(), String>

(Re)draw the whole BasicWorld in the OutputField

Source

fn draw_delta(&mut self) -> Result<(), String>

Draw only the changes that the BasicWorld experienced the previous tick

Source

fn tick_whole(&mut self) -> Result<(), String>

One tick passes in the BasicWorld and the whole BasicWorld is redrawn

Source

fn tick_delta(&mut self) -> Result<(), String>

One tick passes in the BasicWorld and only the deltas are redrawn

Source

fn replace_with_random_world(&mut self) -> Result<(), String>

Replace the Space’s BasicWorld with a random one

Source

fn replace_with_blank_world(&mut self) -> Result<(), String>

Replace the Space’s BasicWorld with a blank wone

Source

fn click_world(&mut self, i: Index)

Propagate a click that happened on the BasicWorld at the Index (x, y)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§