#[derive(Debug)]
pub struct Setup {
uuid: String,
printer_name: String,
}
impl BaseDocument for Setup {
fn new(uuid: String, printer_name: String) -> Self {
Setup { uuid: uuid, printer_name: printer_name }
}
fn get_uuid(&self) -> String {
return self.uuid.clone();
}
fn get_printer_name(&self) -> String {
return self.printer_name.clone();
}
}
#[derive(Debug)]
pub struct PrinterResult {
pub uuid: String,
pub printer_name: String,
pub last_invoice_no: String,
pub last_credit_memo_no: String,
pub last_debit_memo_no: String,
pub last_non_fiscal_no: String,
pub last_closing_no: String,
}
impl PrinterResult {
pub fn get_uuid(&self) -> String {
return self.uuid.clone();
}
pub fn get_printer_name(&self) -> String {
return self.printer_name.clone();
}
}
#[derive(Debug)]
pub struct Report {
uuid: String,
printer_name: String,
}
impl BaseDocument for Report {
fn new(uuid: String, printer_name: String) -> Self {
Report { uuid: uuid, printer_name: printer_name }
}
fn get_uuid(&self) -> String {
return self.uuid.clone();
}
fn get_printer_name(&self) -> String {
return self.printer_name.clone();
}
}
#[derive(Debug)]
pub struct Document {
uuid: String,
printer_name: String,
}
impl BaseDocument for Document {
fn new(uuid: String, printer_name: String) -> Self {
Document { uuid: uuid, printer_name: printer_name }
}
fn get_uuid(&self) -> String {
return self.uuid.clone();
}
fn get_printer_name(&self) -> String {
return self.printer_name.clone();
}
}
pub trait FiscalPrinter {
fn new() -> Self;
fn open_port(&self, _port: String) -> bool;
fn send_command(&self, _command: String) -> bool;
fn setup(&self, _setup: Setup) -> PrinterResult;
fn print_report(&self, _report: Report) -> PrinterResult;
fn print_document(&self, _document: Document) -> PrinterResult;
fn close_port(&self) -> bool;
}
pub trait BaseDocument {
fn new(uuid: String, printer_name: String) -> Self;
fn get_uuid(&self) -> String;
fn get_printer_name(&self) -> String;
}