pub trait RasterDriver:
Sized
+ Send
+ 'static {
type Device: Send + Sync;
// 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<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
options: &'life1 JobOptions,
page: u32,
device: &'life2 Self::Device,
) -> Pin<Box<dyn Future<Output = Result<(), JobFailure>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn end_job<'life0, 'async_trait>(
self,
device: &'life0 Self::Device,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// 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.
start_job/start_page/write_line are synchronous (they only build and
fill the page buffer); the device-touching end_page/end_job are async so
the driver can await a transport (USB HID, Bluetooth RFCOMM, BLE GATT)
without blocking the runtime.
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<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
options: &'life1 JobOptions,
page: u32,
device: &'life2 Self::Device,
) -> Pin<Box<dyn Future<Output = Result<(), JobFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn end_page<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
options: &'life1 JobOptions,
page: u32,
device: &'life2 Self::Device,
) -> Pin<Box<dyn Future<Output = Result<(), JobFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
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".