Skip to content

Commit 1ce4eec

Browse files
committed
Allow specifying attributes when printing.
1 parent 7e4a199 commit 1ce4eec

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ eyre = "0.6.12"
2222
flate2 = "1.0.30"
2323
futures = "0.3.30"
2424
hex = "0.4.3"
25-
ipp = { version = "5.2.0", default-features = false, features = [
26-
"async",
27-
"async-client",
28-
] }
25+
ipp = { version = "5.2.0", default-features = false, features = ["async", "async-client", "serde"] }
2926
jsonwebtoken = "9.3.0"
3027
open = "5.3.0"
3128
regex = "1.11.1"

src/print/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub struct PrintConfig {
1010
#[serde(default = "PrintConfig::default_cups_host")]
1111
cups_host: String,
1212
printer_uri: String,
13+
#[serde(default)]
14+
attributes: Vec<IppAttribute>,
1315
}
1416

1517
impl PrintConfig {
@@ -20,6 +22,8 @@ impl PrintConfig {
2022

2123
pub struct Printer {
2224
ipp_client: AsyncIppClient,
25+
ipp_attributes: Vec<IppAttribute>,
26+
2327
http_client: reqwest::Client,
2428
printer_uri: Uri,
2529
}
@@ -41,6 +45,7 @@ impl Printer {
4145

4246
let printer = Self {
4347
ipp_client,
48+
ipp_attributes: config.attributes,
4449
http_client,
4550
printer_uri,
4651
};
@@ -63,7 +68,9 @@ impl Printer {
6368
let reader = tokio_util::io::StreamReader::new(stream);
6469

6570
let payload = IppPayload::new_async(reader.compat());
66-
let op = IppOperationBuilder::print_job(self.printer_uri.clone(), payload).build();
71+
let op = IppOperationBuilder::print_job(self.printer_uri.clone(), payload)
72+
.attributes(self.ipp_attributes.iter().cloned())
73+
.build();
6774
let resp = self.ipp_client.send(op).await?;
6875

6976
info!(status_code = %resp.header().status_code(), "sent print job");

0 commit comments

Comments
 (0)