Struct Binary

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

A Chip-8 binary

Implementations§

Source§

impl Binary

Source

pub fn new(new_name: &str) -> Result<Binary, BinaryError>

Constructs a new Binary instance

§Argument
  • new_name - The name of the binary file
§Returns

A new Binary instance, wrapped in a Result

Source

pub fn len(&self) -> u16

Gets the length of the binary

§Returns

The length of the binary (in bytes)

Source

pub fn add_instruction( &mut self, instr: &Instruction, ) -> Result<(), BinaryError>

Adds an instruction to the binary

§Argument
  • instr - The Instruction to add
§Returns

Ok if the instruction was added successfully, Err<BinaryError> if the operation fails

Source

pub fn add_word(&mut self, word: u16) -> Result<(), BinaryError>

Adds a 16-bit word to the binary

§Argument
  • word - The word to add
§Returns

Ok if the word was written successfully, Err<BinaryError> if the operation fails

Source

pub fn add_byte(&mut self, byte: u8) -> Result<(), BinaryError>

Adds a byte to the binary

§Argument
  • byte - The byte to add
§Returns

Ok if the byte was written successfully, Err<BinaryError> if the operation fails

Source

pub fn write_to_file(&mut self) -> Result<usize, BinaryError>

Writes the entire binary to a file

§Returns

A Result that on a success contains the number of bytes written, and that on a failure contains a BinaryError object

§Panics

This method will panic if the binary file handle fails to be created successfully.

Auto Trait Implementations§

§

impl Freeze for Binary

§

impl RefUnwindSafe for Binary

§

impl Send for Binary

§

impl Sync for Binary

§

impl Unpin for Binary

§

impl UnwindSafe for Binary

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.