-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod writer; | ||
pub mod reader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::io::{Read, Write}; | ||
use std::collections::VecDeque; | ||
|
||
use rezasm_core::simulation::reader::Reader; | ||
use rezasm_core::util::as_any::AsAny; | ||
|
||
#[derive(Debug)] | ||
pub struct TestReader { | ||
buffer: VecDeque<u8>, | ||
} | ||
|
||
impl TestReader { | ||
pub fn new() -> TestReader { | ||
TestReader { | ||
buffer: VecDeque::new() | ||
} | ||
} | ||
} | ||
|
||
impl Reader for TestReader {} | ||
|
||
impl Read for TestReader { | ||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { | ||
self.buffer.read(buf) | ||
} | ||
} | ||
|
||
impl Write for TestReader { | ||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
self.buffer.write(buf) | ||
} | ||
|
||
fn flush(&mut self) -> std::io::Result<()> { | ||
self.buffer.flush() | ||
} | ||
} | ||
|
||
impl AsAny for TestReader { | ||
fn as_any(&self) -> &dyn std::any::Any { | ||
self | ||
} | ||
|
||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any { | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters