[−][src]Crate ipp
IPP print protocol implementation for Rust. This crate can be used in several ways:
- using the low-level request/response API and building the requests manually.
- using the higher-level operations API with builders. Currently only a subset of all IPP operations is supported.
- using the built-in IPP client based on
reqwest
orisahc
crates. (selected viaclient-isahc
orclient-reqwest
) features. - using any third-party HTTP client and send the serialized request manually.
Implementation notes:
- all RFC IPP values are supported including arrays and collections, for both de- and serialization.
- the Accept-Encoding HTTP header seems to cause problems with some older printers, therefore it is disabled by default.
- this crate is also suitable for building IPP servers, however the example is not provided yet.
- some operations (e.g. CUPS-specific) require authorization which can be supplied in the printer URI.
Usage examples:
// using low-level API use ipp::prelude::*; fn main() -> Result<(), Box<dyn std::error::Error>> { let uri: Uri = "http://localhost:631/printers/test-printer".parse()?; let req = IppRequestResponse::new( IppVersion::v1_1(), Operation::GetPrinterAttributes, Some(uri.clone()) ); let client = IppClient::new(uri); let resp = futures::executor::block_on(client.send_request(req))?; if resp.header().operation_status <= 2 { println!("result: {:?}", resp.attributes()); } Ok(()) }
// using operations API use ipp::prelude::*; fn main() -> Result<(), Box<dyn std::error::Error>> { let uri: Uri = "http://localhost:631/printers/test-printer".parse()?; let operation = IppOperationBuilder::get_printer_attributes(uri.clone()).build(); let client = IppClient::new(uri); let attrs = futures::executor::block_on(client.send(operation))?; for (_, v) in attrs.groups_of(DelimiterTag::PrinterAttributes).next().unwrap().attributes() { println!("{}: {}", v.name(), v.value()); } Ok(()) }
Modules
client | IPP client, selected by |
prelude | Common imports |
proto | IPP protocol implementation |
util | IPP helper functions |