Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mushonnip committed Aug 14, 2024
1 parent 7b3d143 commit c5b3551
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ name = "raw-printer"
description = "Direct RAW printing on windows or linux"
repository = "https://github.com/mushonnip/raw-printer"
keywords = ["printer"]
version = "0.1.2"
version = "0.1.3"
edition = "2021"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
windows = { version = "0.51.1", features = [
[target.'cfg(windows)'.dependencies]
windows = { version = "0.58.0", features = [
"Win32_Foundation",
"Win32_Graphics_Printing",
"Win32_Graphics_Gdi",
] }
]}

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = "symbols"
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn write_to_device(printer: &str, payload: &str) -> Result<usize, std::io::E
};

let printer_name = CString::new(printer).unwrap_or_default(); // null-terminated string
let mut printer_handle: HANDLE = HANDLE(0);
let mut printer_handle: HANDLE = HANDLE(std::ptr::null_mut());

// Open the printer
unsafe {
Expand Down Expand Up @@ -110,8 +110,8 @@ pub fn write_to_device(printer: &str, payload: &str) -> Result<usize, std::io::E
}

// End the page and document
EndPagePrinter(printer_handle);
EndDocPrinter(printer_handle);
let _ = EndPagePrinter(printer_handle);
let _ = EndDocPrinter(printer_handle);
let _ = ClosePrinter(printer_handle);
return Ok(bytes_written as usize);
} else {
Expand Down

0 comments on commit c5b3551

Please sign in to comment.