#[derive(Debug)]
pub struct Setup {
uuid: String,
printer_name: String,
}
pub trait SetupAction {
fn new(uuid: String, printer_name: String) -> Self;
fn get_uuid(&self) -> String;
fn get_printer_name(&self) -> String;
}
impl SetupAction 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,
document_type: String,
}
pub trait ReportAction {
fn new(uuid: String, printer_name: String, document_type: String) -> Self;
fn get_uuid(&self) -> String;
fn get_printer_name(&self) -> String;
fn get_document_type(&self) -> String;
}
impl ReportAction for Report {
fn new(uuid: String, printer_name: String, document_type: String) -> Self {
Report { uuid: uuid, printer_name: printer_name, document_type: document_type }
}
fn get_uuid(&self) -> String {
return self.uuid.clone();
}
fn get_printer_name(&self) -> String {
return self.printer_name.clone();
}
fn get_document_type(&self) -> String {
return self.document_type.clone();
}
}
#[derive(Debug)]
pub struct Document {
uuid: String,
printer_name: String,
}
pub trait DocumentAction {
fn new(uuid: String, printer_name: String) -> Self;
fn get_uuid(&self) -> String;
fn get_printer_name(&self) -> String;
}
impl DocumentAction 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;
}