Struct Instruction
pub struct Instruction { /* private fields */ }
Expand description
An instruction bitstring. Can contain instructions up to 15 bytes long.
Implementations§
§impl Instruction
impl Instruction
pub const fn new(data: &[u8]) -> Instruction
pub const fn new(data: &[u8]) -> Instruction
Creates a new instruction from the provided slice. The slice must be 15 bytes or less.
pub fn into_string(&self) -> String
pub fn into_string(&self) -> String
Converts the instruction into an uppercase hexadecimal string.
pub fn starts_with(&self, p: &Instruction) -> bool
pub fn starts_with(&self, p: &Instruction) -> bool
Returns true if the instruction starts with the prefix p
, followed by zero or more additional bytes.
pub fn set_nth_bit_from_right(&mut self, index: usize, bit: u8)
pub fn set_nth_bit_from_right(&mut self, index: usize, bit: u8)
Sets the bit at position index
, counting from the right.
bit
must be 0
or 1
.
pub fn set_multiple_bits_from_right(
&mut self,
index: usize,
data: u64,
num: usize,
)
pub fn set_multiple_bits_from_right( &mut self, index: usize, data: u64, num: usize, )
Sets multiple bits starting at position index
, counting from the right and moving to the left.
Shifts new bits to insert out of data
.
The lowest bit in data
is inserted first.
§impl Instruction
impl Instruction
pub fn with_nth_bit_from_right_flipped(&self, index: usize) -> Instruction
pub fn with_nth_bit_from_right_flipped(&self, index: usize) -> Instruction
Returns an instruction where the bit at position index
, counting from the right, is flipped.
pub fn with_nth_bit_from_right(&self, index: usize, bit: u8) -> Instruction
pub fn with_nth_bit_from_right(&self, index: usize, bit: u8) -> Instruction
Replaces the bit at position index
, counting from the right, with bit
.
bit
must be 0
or 1
.
pub fn with_nth_bit_from_left(&self, index: usize, bit: u8) -> Instruction
pub fn with_nth_bit_from_left(&self, index: usize, bit: u8) -> Instruction
Replaces the bit at position index
, counting from the left, with bit
.
bit
must be 0
or 1
.
pub fn extend(&self) -> Instruction
pub fn extend(&self) -> Instruction
Extends the instruction with one extra 0-byte. The instruction must be 15 bytes or less.
pub fn resize(&self, num_bytes: usize, fill: u8) -> Instruction
pub fn resize(&self, num_bytes: usize, fill: u8) -> Instruction
Resizes the instruction to be num_bytes
long.
If this is longer than the current instruction, new bytes are filled with the value fill
.
pub fn with_rightmost_bits(&self, num: usize, bit: u8) -> Instruction
pub fn with_rightmost_bits(&self, num: usize, bit: u8) -> Instruction
Replaces the num
rightmost bits in the instruction with value bit
.
pub fn nth_bit_from_right(&self, index: usize) -> u8
pub fn nth_bit_from_right(&self, index: usize) -> u8
Returns the value of the bit at position index
, counting from the right.
pub fn nth_bit_from_left(&self, index: usize) -> u8
pub fn nth_bit_from_left(&self, index: usize) -> u8
Returns the value of the bit at position index
, counting from the left.
Trait Implementations§
§impl<'a> Arbitrary<'a> for Instruction
impl<'a> Arbitrary<'a> for Instruction
§impl Clone for Instruction
impl Clone for Instruction
§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for Instruction
impl Debug for Instruction
§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
§fn deserialize<D>(deserializer: D) -> Result<Instruction, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Instruction, D::Error>where
D: Deserializer<'de>,
§impl<'a> From<&'a [u8]> for Instruction
impl<'a> From<&'a [u8]> for Instruction
§impl From<&Instruction> for InstructionFilter
impl From<&Instruction> for InstructionFilter
§fn from(instr: &Instruction) -> Self
fn from(instr: &Instruction) -> Self
§impl From<Instruction> for InstructionFilter
impl From<Instruction> for InstructionFilter
§fn from(instr: Instruction) -> Self
fn from(instr: Instruction) -> Self
§impl FromIterator<u8> for Instruction
impl FromIterator<u8> for Instruction
§fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self
§impl FromStr for Instruction
impl FromStr for Instruction
§impl Hash for Instruction
impl Hash for Instruction
§impl JsonSchema for Instruction
impl JsonSchema for Instruction
§fn schema_name() -> String
fn schema_name() -> String
§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more§impl LowerHex for Instruction
impl LowerHex for Instruction
§impl Ord for Instruction
impl Ord for Instruction
§impl PartialEq for Instruction
impl PartialEq for Instruction
§impl PartialOrd for Instruction
impl PartialOrd for Instruction
§impl Serialize for Instruction
impl Serialize for Instruction
§impl UpperHex for Instruction
impl UpperHex for Instruction
impl Copy for Instruction
impl Eq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more