Printer

Struct Printer 

Source
pub struct Printer { /* private fields */ }

Implementations§

Source§

impl Printer

Source

pub fn new() -> Printer

Call this function to create a new printer object. It will start with the initial values ESC and @ which initializes the printer. This is done in order to reset the printer to initial state

Source

pub fn add(&mut self, text: Vec<u8>)

Add a list of u8 characters to be printed. This is intended to mainly be used to print plaintext. It could however be used for commands as well.

Source

pub fn add_qr(&mut self, qr: Qr)

Prints the given qr code. The qr code is to be constructed with the qr submodule..

Source

pub fn add_str(&mut self, text: &str)

Add a list of str to be printed. keep in mind that the printer only works on ASCII characters. So it’s the responsibility of the callee to make sure that the string is ASCII. If not then it will most likely be malformed.

Source

pub fn set_double_strike(&mut self, value: u8)

This function will turn on or off double strike mode This is done by giving either the value constants::ON or constants::OFF

Source

pub fn set_emph(&mut self, value: u8)

Call this to either turn on or off emphisized text. This is done by giving either the value constants::ON or constants::OFF

Source

pub fn set_smoothing(&mut self, value: u8)

Call this to turn smoothing on or off This is done by giving either the value constants::ON or constants::OFF

Source

pub fn set_barcode_height(&mut self, height: u8)

This function will set the height of the barcode. The actual height depends on the printer, try and find what works for you. Can be given values between 0-255

Source

pub fn set_barcode_width(&mut self, width: u8)

This function will set the width of the barcode The actual width depends on the printer, try and find what works for you. Can be given values between 2-6 Not sure why this is the case, but it is. Will set to either highest or lowest if out of range.

Source

pub fn add_barcode(&mut self, text: &str, barcode_type: u8, mode: u8)

Prints a given barcode The barcode to print is given as a str There can be different types of barcodes. Check which you want to print https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=128 There are two kinds of ways to print barcode, either constant::MODE_A or constant::MODE_B You have to know which mode is right for you.

Source

pub fn reverse_feed(&mut self, lines: u8)

Call this to reverse feed paper. This is done by giving the number of lines to reverse feed. The maximum number of lines is 255. WARNING: I don’t think this works on most printers

Source

pub fn set_upside_down(&mut self, value: u8)

Call this to either turn on or off upside down text This is done by giving either the value constants::ON or constants::OFF

Source

pub fn set_underline(&mut self, value: u8)

Call this to either set underline text on or off This is done by giving either the value constants::SINGLE, constant::DOUBLE or constants::OFF

Source

pub fn set_line_spacing(&mut self, value: u8)

Call this to change the spacing between lines This is done by giving a value between 0 and 255

Source

pub fn set_default_line_spacing(&mut self)

Call this to set back to the default line spacing

Source

pub fn cut(&mut self)

Source

pub fn print_stdout(&self)

Prints the message straight to stdout

Source

pub fn print_file(&self, path: &str)

Prints the message to a file The path is given as a str

Source

pub fn print(&self, address: String, port: u32) -> Result<(), String>

Sends a printjob to the correct address and port. This requires that other functions adding actions have been called before this.

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.