WordInput

Struct WordInput 

Source
pub struct WordInput { /* private fields */ }
Expand description

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§

Source§

impl WordInput

Source

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

Returns a new WordInput of width width with name name.

Source

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

Sets the lever at index bit to value.

Source

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

Flips the lever at index bit.

Source

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

Sets the lever at index bit to true.

Source

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

Sets the lever at index bit to false.

Source

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

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.

Source

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

Sets all the levers to true.

Source

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

Sets all the levers to false.

Source

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

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

Source

pub fn len(&self) -> usize

Returns the width of the WordInput.

Source

pub fn is_empty(&self) -> bool

Returns true the width of the WordInput == 0.

Auto Trait Implementations§

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.