[][src]Struct logicsim::circuits::WordInput

pub struct WordInput { /* fields omitted */ }

Data Structure that allows you to easily manage a group of LeverHandles.

Example

let input = WordInput::new(&mut g, 3, "input");

let output = g.output(&input.bits(), "result");

let ig = &mut g.init();

assert_eq!(output.u8(ig), 0);

input.set_to(ig, 2);
assert_eq!(output.u8(ig), 2);

input.set_bit(ig, 0);
assert_eq!(output.u8(ig), 3);

input.flip_bit(ig, 1);
assert_eq!(output.u8(ig), 1);

Implementations

impl WordInput[src]

pub fn new<S: Into<String>>(
    g: &mut GateGraphBuilder,
    width: usize,
    name: S
) -> Self
[src]

Returns a new WordInput of width width with name name.

pub fn update_bit(
    &self,
    g: &mut InitializedGateGraph,
    bit: usize,
    value: bool
) -> Option<()>
[src]

Sets the lever at index bit to value.

pub fn flip_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>[src]

Flips the lever at index bit.

pub fn set_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>[src]

Sets the lever at index bit to true.

pub fn reset_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>[src]

Sets the lever at index bit to false.

pub fn set_to<T: Copy + Sized + 'static>(
    &self,
    g: &mut InitializedGateGraph,
    value: T
)
[src]

Sets the levers to the native endian bits of value. If size_of_val(value) > self.len(), it will ignore the excess bits. If size_of_val(value) < self.len(), it will 0 extend the value.

pub fn set(&self, g: &mut InitializedGateGraph)[src]

Sets all the levers to true.

pub fn reset(&self, g: &mut InitializedGateGraph)[src]

Sets all the levers to false.

pub fn bits(&self) -> SmallVec<[GateIndex; 8]>[src]

Returns a SmallVec<GateIndex> to connect to other components.

pub fn len(&self) -> usize[src]

Returns the width of the WordInput.

pub fn is_empty(&self) -> bool[src]

Returns true the width of the WordInput == 0.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.