Skip to main content

Crate product_os_print_server

Crate product_os_print_server 

Source
Expand description

§Product OS Print Server

A complete IPP (Internet Printing Protocol) 1.1 server implementation for Rust.

This crate provides a full-featured IPP print server that can handle print jobs, manage printer attributes, and integrate with the Product OS ecosystem through the capabilities framework.

§Features

  • IPP 1.1 Protocol Support: Complete implementation of the IPP 1.1 specification
  • Bonjour/Zeroconf Discovery: Automatic printer discovery on the network
  • Async/Await Support: Built on tokio for high-performance async I/O
  • Flexible Job Processing: Pluggable processor trait for custom print handling
  • Product OS Integration: Seamless integration with Product OS capabilities

§Quick Start

use product_os_print_server::{ProductOSIPPServer, ProductOSIPPProcessor};
use std::sync::Arc;
use async_trait::async_trait;
use product_os_utilities::ProductOSError;

// Implement a custom print processor
struct MyProcessor;

#[async_trait]
impl ProductOSIPPProcessor for MyProcessor {
    async fn process(&self, id: usize, data: Vec<u8>) -> Result<(), ProductOSError> {
        // Handle print job data
        println!("Processing job {} with {} bytes", id, data.len());
        Ok(())
    }

    async fn cancel(&self, id: usize) -> Result<(), ProductOSError> {
        println!("Cancelling job {}", id);
        Ok(())
    }
}

// Create and configure the print server
let processor = Arc::new(MyProcessor);
let server = ProductOSIPPServer::new(
    "My Printer".to_string(),
    "ipp://localhost:631/printers/my-printer".to_string(),
    631,
    false,
    processor
);

§Architecture

The print server is built around several key components:

  • ProductOSIPPServer: The main server struct that manages the printer and handles requests
  • ProductOSIPPProcessor: A trait for implementing custom print job processing
  • Encoder/Decoder: Handles IPP protocol encoding and decoding
  • Printer Management: Manages printer state, attributes, and job queue

§IPP Operations Supported

  • Print-Job
  • Validate-Job
  • Get-Printer-Attributes
  • Get-Jobs
  • Cancel-Job
  • Get-Job-Attributes

§Cargo Features

FeatureDefaultDescription
stdYesStandard library support (serde/std, serde_json/std)
compressionYesIPP data compression/decompression via flate2
discoveryYesBonjour/Zeroconf network printer discovery
loggingYesStructured logging via tracing
minimalNoMinimal build with no optional dependencies
serde-supportNoDeprecated – no-op
job-namingNoDeprecated – no-op

§Security

The server supports both IPP (insecure) and IPPS (secure over TLS) modes. Set the is_secure parameter when creating the server to enable TLS.

Structs§

ProductOSIPPServer
The main IPP print server.

Traits§

ProductOSIPPProcessor
A trait for implementing custom print job processing.