pub enum Instruction {
Compound {
instructions: Vec<Instruction>,
},
Command {
command: Command,
},
VSpace {
lines: u8,
},
Text {
content: String,
markdown: bool,
font: Font,
justification: Justification,
replacements: Option<HashSet<String>>,
},
DuoTable {
name: String,
header: (String, String),
font: Font,
},
TrioTable {
name: String,
header: (String, String, String),
},
QuadTable {
name: String,
header: (String, String, String),
},
Image {
image: EscposImage,
},
QRCode {
name: String,
},
Cut,
}
Expand description
Templates for recurrent prints
The Instruction structure allows the creation of template prints, which could contain certain data that should change between prints (be it text, tables, or even qr codes).
It is not adviced to construct the variants of the enum manually, read the available functions to guarantee a predictable outcome.
Variants§
Compound
Compound instruction, composed of multiple instructions that must be executed sequentially
Fields
instructions: Vec<Instruction>
Command
An instruction consisting of a single esc/pos
command
VSpace
Short for jumping a specified number of lines
Text
Raw text
Fields
justification: Justification
Justification of the content
DuoTable
2 column table
Fields
TrioTable
Table with three columns. Might be to tight for 50mm printers
QuadTable
Fancy table for really detailed prints
Image
Contains a static image, that is, does not change with different printing mechanisms
Fields
image: EscposImage
Inner image
QRCode
Prints a QR Code. This field is dynamic
Cut
Cuts the paper in place. Only for supported printers
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub fn is_compound(&self) -> bool
pub fn is_compound(&self) -> bool
Returns true if the instruction is compund
Sourcepub fn text<A: Into<String>>(
content: A,
font: Font,
justification: Justification,
replacements: Option<HashSet<String>>,
) -> Instruction
pub fn text<A: Into<String>>( content: A, font: Font, justification: Justification, replacements: Option<HashSet<String>>, ) -> Instruction
Sends simple text to the printer.
Straightfoward text printing. The replacements
set specifies which contents of the string should be replaced in a per-impresion basis.
Sourcepub fn markdown(
content: String,
font: Font,
justification: Justification,
replacements: Option<HashSet<String>>,
) -> Instruction
pub fn markdown( content: String, font: Font, justification: Justification, replacements: Option<HashSet<String>>, ) -> Instruction
Sends markdown text to the printer
Allows markdown to be sent to the printer. Not everything is supported, so far the following list works (if the printer supports the corresponding fonts)
- Bold font, with **
- Italics, with _
Sourcepub fn image(image: EscposImage) -> Result<Instruction, Error>
pub fn image(image: EscposImage) -> Result<Instruction, Error>
Prints an image
For a more precise control of position in the image, it is easier to edit the input image beforehand.
Sourcepub fn qr_code(content: String) -> Result<Instruction, Error>
pub fn qr_code(content: String) -> Result<Instruction, Error>
Creates a new QR code that does not change through different print steps
Sourcepub fn dynamic_qr_code<A: Into<String>>(name: A) -> Instruction
pub fn dynamic_qr_code<A: Into<String>>(name: A) -> Instruction
Creates a dynamic qr code instruction, which requires a string at printing time
Sourcepub fn command(command: Command) -> Instruction
pub fn command(command: Command) -> Instruction
Executes a raw escpos command.
Sourcepub fn duo_table<A: Into<String>, B: Into<String>, C: Into<String>>(
name: A,
header: (B, C),
font: Font,
) -> Instruction
pub fn duo_table<A: Into<String>, B: Into<String>, C: Into<String>>( name: A, header: (B, C), font: Font, ) -> Instruction
Creates a table with two columns.
Sourcepub fn trio_table<A: Into<String>, B: Into<String>, C: Into<String>, D: Into<String>>(
name: A,
header: (B, C, D),
) -> Instruction
pub fn trio_table<A: Into<String>, B: Into<String>, C: Into<String>, D: Into<String>>( name: A, header: (B, C, D), ) -> Instruction
Creates a table with three columns
Sourcepub fn quad_table<A: Into<String>, B: Into<String>, C: Into<String>, D: Into<String>>(
name: A,
header: (B, C, D),
) -> Instruction
pub fn quad_table<A: Into<String>, B: Into<String>, C: Into<String>, D: Into<String>>( name: A, header: (B, C, D), ) -> Instruction
Creates a table with four columns
Tables with four columns can be quite tight in 80mm printers, and unthinkable in 58mm ones or smaller. Use with caution!
Sourcepub fn cut() -> Instruction
pub fn cut() -> Instruction
Cuts the paper (if supported)
Sourcepub fn vspace(lines: u8) -> Instruction
pub fn vspace(lines: u8) -> Instruction
Moves the paper a certain amount of vertical spaces
Trait Implementations§
Source§impl Add for Instruction
Instruction addition
impl Add for Instruction
Instruction addition
Source§type Output = Instruction
type Output = Instruction
+
operator.Source§impl AddAssign for Instruction
Mutable addition for instructions
impl AddAssign for Instruction
Mutable addition for instructions
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moreSource§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromIterator<Instruction> for Option<Instruction>
From iterator operation for a vector of instructions
impl FromIterator<Instruction> for Option<Instruction>
From iterator operation for a vector of instructions
Source§fn from_iter<I: IntoIterator<Item = Instruction>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Instruction>>(iter: I) -> Self
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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