write_to_device

Function write_to_device 

Source
pub fn write_to_device(
    printer: &str,
    payload: &[u8],
    _document_name: Option<&str>,
) -> Result<usize, Error>
Expand description

§Platform-specific Behavior

This function returns a result containing the size of bytes written on success or an error.

  • On Linux and Windows, the result type is Result<usize, Error>.
  • Note: On Windows, the original bytes written are u32 but cast to usize.

§Examples

let zpl = "^FDhello world";
let printer = "/dev/usb/lp0";
let result = raw_printer::write_to_device(printer, zpl, Some("My Custom Document"));

assert!(result.is_ok());