[−][src]Struct pir_8_emu::binutils::pir_8_as::OutputWithQueue
Output sink which transparently waits for labels to be saved
Examples
let mut dest = vec![]; let mut output = OutputWithQueue::new(&mut dest); let mut labels = BTreeMap::new(); output.write_all(&[0xFE], &labels).unwrap(); assert_eq!(&dest, &[0xFEu8]); output.wait_for_label("OwO".to_string(), 0, LabelFragment::Full); output.write_all(&[0xFF], &labels).unwrap(); assert_eq!(&dest, &[0xFEu8]); output.wait_for_label("OwO".to_string(), 0x0F, LabelFragment::Low); output.write_all(&[0xFF], &labels).unwrap(); assert_eq!(&dest, &[0xFEu8]); output.wait_for_label("eWe".to_string(), 0, LabelFragment::Full); output.write_all(&[0x4C], &labels).unwrap(); assert_eq!(&dest, &[0xFEu8]); output.wait_for_label("ЦшЦ".to_string(), 0, LabelFragment::Full); output.write_all(&[0xEC], &labels).unwrap(); assert_eq!(&dest, &[0xFEu8]); labels.insert("OwO".to_string(), 0x0110); labels.insert("ЦшЦ".to_string(), 0x0420); output.write_all(&[0xFA], &labels).unwrap(); assert_eq!(&dest, &[0xFEu8, 0x01, 0x10, 0xFF, 0x1F, 0xFF]); assert_eq!(output.unfound_labels(&labels), Some(vec!["eWe".to_string()].into_iter().collect()));
Methods
impl OutputWithQueue
[src]
pub fn new<W: Write + 'static>(output: W) -> OutputWithQueue
[src]
Create an unqueued output, writing to the specified destination
pub fn wait_for_label(
&mut self,
label: String,
offset: i16,
fragment: LabelFragment
)
[src]
&mut self,
label: String,
offset: i16,
fragment: LabelFragment
)
Queue all output going forward until a label with the specified name shows up, and offset it by the specified amount
pub fn write_all(
&mut self,
buf: &[u8],
labels: &BTreeMap<String, u16>
) -> Result<()>
[src]
&mut self,
buf: &[u8],
labels: &BTreeMap<String, u16>
) -> Result<()>
Write the specified bytes to the output or queue them
Calls flush()
first
If afterward, the label buffer is not empty, queue the specified buffer at the end
Otherwise, write the specified buffer directly to the output device
pub fn flush(&mut self, labels: &BTreeMap<String, u16>) -> Result<()>
[src]
Attempt to clear the label queue
There's no need to call this explicitly,
as write_all()
will call this funxion before performing any output
If the label at the front of the queue is present in the specified labelset write its address, then the buffer queued behind it, and pop it off
This repeats until the queue is empty or the label thereatfront doesn't exist in the labelset
pub fn unfound_labels(
self,
labels: &BTreeMap<String, u16>
) -> Option<BTreeSet<String>>
[src]
self,
labels: &BTreeMap<String, u16>
) -> Option<BTreeSet<String>>
Get all remaining queued labels not present in the specified labelset, or None
if all were
Auto Trait Implementations
impl !RefUnwindSafe for OutputWithQueue
impl !Send for OutputWithQueue
impl !Sync for OutputWithQueue
impl Unpin for OutputWithQueue
impl !UnwindSafe for OutputWithQueue
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,