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
impl WordInput
Sourcepub fn new<S: Into<String>>(
g: &mut GateGraphBuilder,
width: usize,
name: S,
) -> Self
pub fn new<S: Into<String>>( g: &mut GateGraphBuilder, width: usize, name: S, ) -> Self
Returns a new WordInput of width width with name name.
Sourcepub fn update_bit(
&self,
g: &mut InitializedGateGraph,
bit: usize,
value: bool,
) -> Option<()>
pub fn update_bit( &self, g: &mut InitializedGateGraph, bit: usize, value: bool, ) -> Option<()>
Sets the lever at index bit to value.
Sourcepub fn flip_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
pub fn flip_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
Flips the lever at index bit.
Sourcepub fn set_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
pub fn set_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
Sets the lever at index bit to true.
Sourcepub fn reset_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
pub fn reset_bit(&self, g: &mut InitializedGateGraph, bit: usize) -> Option<()>
Sets the lever at index bit to false.
Sourcepub fn set_to<T: Copy + Sized + 'static>(
&self,
g: &mut InitializedGateGraph,
value: T,
)
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.
Sourcepub fn set(&self, g: &mut InitializedGateGraph)
pub fn set(&self, g: &mut InitializedGateGraph)
Sets all the levers to true.
Sourcepub fn reset(&self, g: &mut InitializedGateGraph)
pub fn reset(&self, g: &mut InitializedGateGraph)
Sets all the levers to false.
Auto Trait Implementations§
impl Freeze for WordInput
impl RefUnwindSafe for WordInput
impl Send for WordInput
impl Sync for WordInput
impl Unpin for WordInput
impl UnwindSafe for WordInput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more