| Name | Message | Date |
|---|---|---|
| 📄 escpos_printer.rs | 1 month ago | |
| 📄 mod.rs | 1 month ago | |
| 📄 receipt_printer_actor.rs | 1 month ago | |
| 📄 receipt_printer_error.rs | 1 month ago |
📄
src/receipt_printer/receipt_printer_error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::fmt::Display; use escpos::errors::PrinterError; use tokio::sync::{mpsc, oneshot}; use super::receipt_printer_actor::EscposPrinterRequest; pub struct ReceiptPrinterError { variant: ReceiptPrinterErrorVariants, } impl ReceiptPrinterError { pub fn send(send_error: mpsc::error::SendError<EscposPrinterRequest>) -> Self { Self { variant: ReceiptPrinterErrorVariants::Send(send_error), } } pub fn receive(recv_error: oneshot::error::RecvError) -> Self { Self { variant: ReceiptPrinterErrorVariants::Receive(recv_error), } } pub fn printer(printer_error: PrinterError) -> Self { Self { variant: ReceiptPrinterErrorVariants::Printer(printer_error), } } } enum ReceiptPrinterErrorVariants { Send(mpsc::error::SendError<EscposPrinterRequest>), Receive(oneshot::error::RecvError), Printer(PrinterError), } impl Display for ReceiptPrinterError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.variant { ReceiptPrinterErrorVariants::Send(send_error) => send_error.fmt(f), ReceiptPrinterErrorVariants::Receive(recv_error) => recv_error.fmt(f), ReceiptPrinterErrorVariants::Printer(printer_error) => printer_error.fmt(f), } } }