use std::io::{Read, Write};
pub const OKAY: u64 = 0;
pub const UNDERFLOW: u64 = 1;
pub const OVERFLOW: u64 = 2;
pub struct RtsState<'a> {
input: &'a mut Read,
output: &'a mut Write,
}
impl<'a> RtsState<'a> {
pub fn new<R: Read, W: Write>(input: &'a mut R, output: &'a mut W) -> Self {
RtsState { input, output,
}
}
pub extern "win64" fn read(&mut self) -> u8 {
let mut buf = [0];
let _ = self.input.read_exact(&mut buf);
buf[0]
}
pub extern "win64" fn write(&mut self, byte: u8) {
let _ = self.output.write_all(&[byte]);
}
pub extern "C" fn read_c(&mut self) -> u8 {
let mut buf = [0];
let _ = self.input.read_exact(&mut buf);
buf[0]
}
pub extern "C" fn write_c(&mut self, byte: u8) {
let _ = self.output.write_all(&[byte]);
}
}