embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

PrinterHost

Struct PrinterHost 

Source
pub struct PrinterHost<'d, A: UsbHostAllocator<'d>> { /* private fields */ }
Expand description

USB Printer host driver.

Implementations§

Source§

impl<'d, A: UsbHostAllocator<'d>> PrinterHost<'d, A>

Source

pub fn new( alloc: &A, enum_info: &EnumerationInfo, config_desc: &[u8], ) -> Result<Self, PrinterError>

Create a new USB printer host instance.

Source

pub fn info(&self) -> &PrinterInfo

Return descriptor-located info.

Source

pub async fn write(&mut self, data: &[u8]) -> Result<usize, PrinterError>

Write print data (e.g. ESC/POS, text, graphics) to the printer.

Source

pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, PrinterError>

Read data from a bi-directional printer.

Source

pub async fn get_device_id( &mut self, buf: &mut [u8], ) -> Result<usize, PrinterError>

Query the IEEE 1284 Device ID string from the printer.

Copies the ASCII string into buf and returns the string length.

Source

pub async fn get_port_status(&mut self) -> Result<PortStatus, PrinterError>

Query current port status flags (error, selected/online, paper empty).

Source

pub async fn soft_reset(&mut self) -> Result<(), PrinterError>

Issue a soft reset request to the printer.

Trait Implementations§

Source§

impl<'d, A: UsbHostAllocator<'d>> ErrorType for PrinterHost<'d, A>

Available on crate feature embedded-io only.
Source§

type Error = PrinterError

Error type of all the IO operations on this type.
Source§

impl<'d, A: UsbHostAllocator<'d>> Read for PrinterHost<'d, A>

Available on crate feature embedded-io only.
Source§

async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<'d, A: UsbHostAllocator<'d>> Write for PrinterHost<'d, A>

Available on crate feature embedded-io only.
Source§

async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

async fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
Source§

async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more

Auto Trait Implementations§

§

impl<'d, A> Forget for PrinterHost<'d, A>

§

impl<'d, A> Freeze for PrinterHost<'d, A>

§

impl<'d, A> Move for PrinterHost<'d, A>

§

impl<'d, A> RefUnwindSafe for PrinterHost<'d, A>

§

impl<'d, A> Send for PrinterHost<'d, A>
where <A as UsbHostAllocator<'d>>::Pipe<Control, InOut>: Send, <A as UsbHostAllocator<'d>>::Pipe<Bulk, Out>: Send, Option<<A as UsbHostAllocator<'d>>::Pipe<Bulk, In>>: Send,

§

impl<'d, A> Sync for PrinterHost<'d, A>
where <A as UsbHostAllocator<'d>>::Pipe<Control, InOut>: Sync, <A as UsbHostAllocator<'d>>::Pipe<Bulk, Out>: Sync, Option<<A as UsbHostAllocator<'d>>::Pipe<Bulk, In>>: Sync,

§

impl<'d, A> Unpin for PrinterHost<'d, A>

§

impl<'d, A> UnsafeUnpin for PrinterHost<'d, A>

§

impl<'d, A> UnwindSafe for PrinterHost<'d, A>

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, 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.