mod ascii;
mod base256;
mod c40;
mod edifact;
mod text;
mod x12;
mod frac;
mod generic;
mod shortest_path;
use frac::Frac;
pub(crate) use shortest_path::optimize;
trait ContextInformation: Clone {
fn symbol_size_left(&self, extra_chars: usize) -> Option<usize>;
fn rest(&self) -> &[u8];
fn eat(&mut self) -> Option<u8>;
fn write(&mut self, bytes: usize);
fn peek(&self, n: usize) -> Option<u8> {
self.rest().get(n).copied()
}
fn characters_left(&self) -> usize {
self.rest().len()
}
fn has_more_characters(&self) -> bool {
!self.rest().is_empty()
}
}
#[derive(Debug, PartialEq)]
struct StepResult {
end: bool,
unbeatable: bool,
}
trait Plan: Clone {
type Context;
fn mode_switch_cost(&self) -> Option<Frac>;
fn cost(&self) -> Frac;
fn step(&mut self) -> Option<StepResult>;
fn write_unlatch(&self) -> Self::Context;
}