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 stateful — start_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§
Required Methods§
Sourcefn start_job(
printer: &PrinterHandle<'_>,
options: &JobOptions,
device: &Self::Device,
) -> Result<Self, JobFailure>
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.
Sourcefn write_line(
&mut self,
options: &JobOptions,
y: u32,
line: &[u8],
) -> Result<(), JobFailure>
fn write_line( &mut self, options: &JobOptions, y: u32, line: &[u8], ) -> Result<(), JobFailure>
Append one scanline to the page buffer.
Sourcefn end_page(
&mut self,
options: &JobOptions,
page: u32,
device: &Self::Device,
) -> Result<(), JobFailure>
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).
Provided Methods§
Sourcefn start_page(
&mut self,
_options: &JobOptions,
_page: u32,
_device: &Self::Device,
) -> Result<(), JobFailure>
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".