Skip to main content

RasterDriver

Trait RasterDriver 

Source
pub trait RasterDriver:
    Sized
    + Send
    + 'static {
    type Device: Send;

    // Required methods
    fn start_job(
        printer: &PrinterHandle<'_>,
        options: &JobOptions,
        device: &Self::Device,
    ) -> Result<Self, JobFailure>;
    fn write_line(
        &mut self,
        options: &JobOptions,
        y: u32,
        line: &[u8],
    ) -> Result<(), JobFailure>;
    fn end_page(
        &mut self,
        options: &JobOptions,
        page: u32,
        device: &Self::Device,
    ) -> Result<(), JobFailure>;
    fn end_job(self, device: &Self::Device);

    // Provided method
    fn start_page(
        &mut self,
        _options: &JobOptions,
        _page: u32,
        _device: &Self::Device,
    ) -> Result<(), JobFailure> { ... }
}
Expand description

Driver that turns a stream of raster scanlines into device bytes.

Implementations are per-job statefulstart_job returns a fresh value that owns the page buffer, write_line accumulates scanlines, end_page transfers the page to the device, end_job releases resources. The framework’s IPP Print-Job handler drives this trait; you only need to provide a type that knows how to talk to your device.

Required Associated Types§

Source

type Device: Send

The driver’s opaque device handle (e.g. an open HID descriptor).

Required Methods§

Source

fn start_job( printer: &PrinterHandle<'_>, options: &JobOptions, device: &Self::Device, ) -> Result<Self, JobFailure>

Allocate per-job state. Called once at the top of each job.

Source

fn write_line( &mut self, options: &JobOptions, y: u32, line: &[u8], ) -> Result<(), JobFailure>

Append one scanline to the page buffer.

Source

fn end_page( &mut self, options: &JobOptions, page: u32, device: &Self::Device, ) -> Result<(), JobFailure>

Transfer the completed page to the device (and repeat for copies).

Source

fn end_job(self, device: &Self::Device)

Release per-job state. Called once at the end of the job.

Provided Methods§

Source

fn start_page( &mut self, _options: &JobOptions, _page: u32, _device: &Self::Device, ) -> Result<(), JobFailure>

Called once per page before any write_line. Default: no-op.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§