List available printers or use default printer?

Hello

I am currently working on a small program to allow restaurants to automatically print receipts of incoming orders on their thermal receipt printers.

Currently I am using the crate Recibo, which is working fine. But I need to initialize the printer with this code:

    let driver = FileDriver::new(r#"\\.\COM3"#).unwrap();

Right now I am manually entering the port of the connected printer. I don't want my end-users to have to configure their printer by entering the USB-port/Network location.

Is there a way in Rust to list the available printers or to just print to the default printer?

Can you check the docs for these sorts of printers? They might have suggestions for automatic discovery.

Otherwise for USB, you can probably use a USB library to list all attached USB devices and search for something that looks relevant.

Listing the available printers is more of a Windows-API question than a Rust question (I'm assuming you're on Windows).
You would need to call the EnumPrinters function in the Windows API. Here's a thread where someone had to do that from Rust (HIH):

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.