Crate ipp

Crate ipp 

Source
Expand description

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.
  • using any third-party HTTP client and send the serialized request manually.

This crate supports both synchronous and asynchronous operations. The following feature flags are supported:

  • async - enables asynchronous APIs.
  • async-client - enables an asynchronous IPP client based on reqwest crate, implies async feature.
  • async-client-rustls - enables an asynchronous IPP client with TLS, using rustls backend. Implies async-client feature.
  • async-client-tls - enables an asynchronous IPP client with TLS, using native-tls backend. Implies async-client feature.
  • client - enables a blocking IPP client based on ureq crate.
  • client-rustls - enables a blocking IPP client with TLS, using rustls backend. Implies client feature.
  • client-tls - enables a blocking IPP client with TLS, using native-tls backend. Implies client feature.

By default, the async-client-rustls feature is enabled. Some old printers may not support the latest TLS standards; in that case you can choose to use async-client-tls or client-tls, which will use platform-specific native-tls.

Implementation notes:

  • all RFC IPP values are supported, including arrays and collections, for both de- and serialization.
  • this crate is also suitable for building the IPP servers; however, the example is not provided yet.

Usage examples:

 // using low-level async API
 use ipp::prelude::*;

 #[tokio::main]
 async 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 = AsyncIppClient::new(uri);
     let resp = client.send(req).await?;
     if resp.header().status_code().is_success() {
         println!("{:?}", resp.attributes());
     }
     Ok(())
 }
 // using blocking 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 resp = client.send(operation)?;
     if resp.header().status_code().is_success() {
         println!("{:?}", resp.attributes());
     }
     Ok(())
 }

Modules§

attribute
Attribute-related structs
client
IPP client
error
IPP error
model
Base IPP definitions and tags
operation
High-level IPP operation abstractions
parser
IPP stream parser
payload
IPP payload
prelude
Common imports
reader
IPP reader
request
IPP request
util
IPP helper functions
value
IPP value

Structs§

IppHeader
IPP request and response header