[][src]Trait virt_ic::chip::Chip

pub trait Chip {
    fn get_uuid(&self) -> u128;
fn get_type(&self) -> &str;
fn run(&mut self, elapsed_time: Duration);
fn get_pin_qty(&self) -> u8;
fn _get_pin(&mut self, pin: u8) -> Rc<RefCell<Pin>>;
fn get_info(&self) -> ChipInfo; fn get_pin(&mut self, pin: u8) -> Result<Rc<RefCell<Pin>>, &str> { ... }
fn get_pin_state(&mut self, pin: u8) -> State { ... }
fn set_pin_state(&mut self, pin: u8, state: &State) { ... }
fn save(&self) -> SavedChip { ... }
fn save_data(&self) -> Vec<String> { ... }
fn load(&mut self, saved_chip: &SavedChip) { ... }
fn load_data(&mut self, _chip_data: &[String]) { ... } }

Chip : a trait that represents chips on board

Required methods

fn get_uuid(&self) -> u128

Give a unique id to maintain continuity when saving.
This uuid must not maintain any information other that identity.
When saving, this value will be used to link the traced pins to their respective chip.

fn get_type(&self) -> &str

Give a unique name for the chip struct, it must be the same for every chips of the same struct.
This value will be used to rebuild the correct Struct based on this name with the help of the chip factory

fn run(&mut self, elapsed_time: Duration)

Runs the chip for a certain amount of time

fn get_pin_qty(&self) -> u8

Returns the number of pins the chip has

fn _get_pin(&mut self, pin: u8) -> Rc<RefCell<Pin>>

Get a pin of the chip. Pin will be in safe range (1..pin_qty)
There is no way that you don't provide a pin since you have said in pin_qty how many pins your chip have

fn get_info(&self) -> ChipInfo

Get chip generic informations and data

Loading content...

Provided methods

fn get_pin(&mut self, pin: u8) -> Result<Rc<RefCell<Pin>>, &str>

Get a pin of the chip

fn get_pin_state(&mut self, pin: u8) -> State

Get the state of the specified Pin

fn set_pin_state(&mut self, pin: u8, state: &State)

Set the state of the specified Pin

fn save(&self) -> SavedChip

Save the chip to a SavedChip struct

fn save_data(&self) -> Vec<String>

Create a Vec of String that must contain every information you need to restore your chip to a certain state.
This will be saved in the resulting file.

fn load(&mut self, saved_chip: &SavedChip)

Restore the chip from a SavedChip struct

fn load_data(&mut self, _chip_data: &[String])

Using the array of String you provided in save_data , you must restore the state of your chip.

Loading content...

Trait Implementations

impl Debug for dyn Chip[src]

Implementors

impl Chip for Button[src]

impl Chip for Clock100Hz[src]

impl Chip for Clock1kHz[src]

impl Chip for SimpleCPU[src]

impl Chip for GateAnd[src]

impl Chip for GateNot[src]

impl Chip for GateOr[src]

impl Chip for Generator[src]

impl Chip for Ram256B[src]

impl Chip for Rom256B[src]

impl Chip for Socket[src]

Loading content...