Skip to main content

FilePrinterDevice

Struct FilePrinterDevice 

Source
pub struct FilePrinterDevice<T: FilePrinterProvider> { /* private fields */ }
Expand description

A virtual “print-to-file” printer device backed by a built-in Windows driver.

Each instance installs a freshly-created printer port (a unique temp file) and a printer using the driver supplied by T. Dropping the value removes the printer, the port, and the backing temp file. Unlike null_device, this type is not thread-local or shared ? each FilePrinterDevice owns its own printer; if you need several, construct several.

use winprint_ext::test_utils::file_device::{FilePrinterDevice, PwgRaster};

let dev = FilePrinterDevice::<PwgRaster>::new().unwrap();
println!("printer: {}", dev.device().name());
println!("output:  {}", dev.file_path().display());
// ... use dev.device() for printing ...

Implementations§

Source§

impl<T: FilePrinterProvider> FilePrinterDevice<T>

Source

pub fn new() -> Result<Self>

Create a new virtual “print-to-file” printer.

On first call per-process (per driver) this installs the driver and cleans up leftover printers from previous crashed runs. Subsequent calls only create the port and printer.

Source

pub fn device(&self) -> &PrinterDevice

Returns the underlying PrinterDevice.

Source

pub fn file_path(&self) -> &Path

Returns the path to the backing file that the driver spools its output into.

Trait Implementations§

Source§

impl<T: FilePrinterProvider> Drop for FilePrinterDevice<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FilePrinterDevice<T>
where PhantomData<fn() -> T>: Freeze,

§

impl<T> RefUnwindSafe for FilePrinterDevice<T>
where PhantomData<fn() -> T>: RefUnwindSafe,

§

impl<T> Send for FilePrinterDevice<T>
where PhantomData<fn() -> T>: Send,

§

impl<T> Sync for FilePrinterDevice<T>
where PhantomData<fn() -> T>: Sync,

§

impl<T> Unpin for FilePrinterDevice<T>
where PhantomData<fn() -> T>: Unpin,

§

impl<T> UnsafeUnpin for FilePrinterDevice<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

§

impl<T> UnwindSafe for FilePrinterDevice<T>
where PhantomData<fn() -> T>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.