| Name | Message | Date |
|---|---|---|
| 📄 escpos_printer.rs | 1 month ago | |
| 📄 main.rs | 1 month ago | |
| 📄 proto.rs | - | |
| 📄 receipt_printer_service.rs | 1 month ago | |
| 📄 typst_renderer.rs | 1 month ago |
📄
src/main.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
mod escpos_printer; mod proto; mod receipt_printer_service; mod typst_renderer; use std::env::args; use tonic::transport::Server; use crate::proto::receipt_printer_server::ReceiptPrinterServer; use crate::receipt_printer_service::ReceiptPrinterService; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let args: Vec<_> = args().skip(1).collect(); if args.len() != 2 { println!("Please provide the printer connection string and .typ template as arguments"); return Ok(()); }; let Some((printer_host, printer_port)) = args[0] .split_once(':') .and_then(|(a, b)| b.parse::<u16>().ok().map(|b| (a, b))) else { println!("Printer connection string must be on format `host:port`"); return Ok(()); }; let template_path = &args[1]; let receipt_printer_service = ReceiptPrinterService::new( template_path.to_owned(), printer_host.to_owned(), printer_port, ); Server::builder() .add_service(ReceiptPrinterServer::new(receipt_printer_service)) .serve("[::1]:50051".parse()?) .await?; Ok(()) }