pub struct Printer<D> { /* private fields */ }Implementations§
Source§impl<D> Printer<D>where
D: PrinterDevice,
impl<D> Printer<D>where
D: PrinterDevice,
Sourcepub fn markdown<'a, I>(
&mut self,
iter: I,
opts: &MarkdownRenderOptions,
) -> Result<&mut Self>
pub fn markdown<'a, I>( &mut self, iter: I, opts: &MarkdownRenderOptions, ) -> Result<&mut Self>
Examples found in repository?
More examples
Source§impl<D> Printer<D>
impl<D> Printer<D>
pub fn builder() -> PrinterConfig
pub fn new(device: D, config: PrinterConfig) -> Result<Self>
Source§impl<D> Printer<D>where
D: PrinterDevice,
impl<D> Printer<D>where
D: PrinterDevice,
Sourcepub fn cut(&mut self) -> Result<&mut Self>
pub fn cut(&mut self) -> Result<&mut Self>
Examples found in repository?
More examples
examples/lena.rs (line 17)
5fn main() -> Result<()> {
6 let img = image::open("./examples/lena.jpg").unwrap();
7 PrinterConfig::tm_t20ii()
8 .build(io::stdout())?
9 .reset()?
10 .println("dithered:")?
11 .image(&EscposImage::new(&img, &Default::default()))?
12 .println("threshold:")?
13 .image(&EscposImage::new(
14 &img,
15 &ImageOptions::default().bit_map_algorithm(BitMapAlgorithm::Threshold(80)),
16 ))?
17 .cut()?;
18 Ok(())
19}examples/justification.rs (line 20)
6fn main() -> Result<()> {
7 let img = image::open("./examples/lena.jpg").unwrap();
8 let escpos_img = EscposImage::new(&img, ImageOptions::default().scale(0.3)?);
9 PrinterConfig::tm_t20ii()
10 .build(io::stdout())?
11 .reset()?
12 .println("Left: Hello world!")?
13 .image(&escpos_img)?
14 .justification(Justification::Center)?
15 .println("Center: Hello world!")?
16 .image(&escpos_img)?
17 .justification(Justification::Right)?
18 .println("Right: Hello world!")?
19 .image(&escpos_img)?
20 .cut()?;
21 Ok(())
22}examples/left_margin.rs (line 23)
8fn main() -> Result<()> {
9 let img = image::open("./examples/lena.jpg").unwrap();
10 let escpos_img = EscposImage::new(&img, &Default::default());
11 PrinterConfig::tm_t20ii()
12 .build(io::stdout())?
13 .reset()?
14 .left_margin(100)?
15 .println(format!("Left margin {}: {}", 100, LOREM_IPSUM))?
16 .image(&escpos_img)?
17 .left_margin(200)?
18 .println(format!("Left margin {}: {}", 200, LOREM_IPSUM))?
19 .left_margin(300)?
20 .println(format!("Left margin {}: {}", 300, LOREM_IPSUM))?
21 .reset()?
22 .println(format!("Left margin {}: {}", 0, LOREM_IPSUM))?
23 .cut()?;
24 Ok(())
25}Additional examples can be found in:
pub fn init(&mut self) -> Result<&mut Self>
pub fn print_mode_default(&mut self) -> Result<&mut Self>
pub fn charset(&mut self, charset: Charset) -> Result<&mut Self>
pub fn code_table(&mut self, code_table: CodeTable) -> Result<&mut Self>
pub fn font(&mut self, font: Font) -> Result<&mut Self>
pub fn underline(&mut self, thickness: UnderlineThickness) -> Result<&mut Self>
pub fn bold(&mut self, enabled: bool) -> Result<&mut Self>
pub fn double_strike(&mut self, enabled: bool) -> Result<&mut Self>
pub fn white_black_reverse(&mut self, enabled: bool) -> Result<&mut Self>
pub fn char_size( &mut self, magnification: CharMagnification, ) -> Result<&mut Self>
pub fn split_words(&mut self, enabled: bool) -> Result<&mut Self>
Sourcepub fn left_margin(&mut self, margin: u16) -> Result<&mut Self>
pub fn left_margin(&mut self, margin: u16) -> Result<&mut Self>
Examples found in repository?
examples/left_margin.rs (line 14)
8fn main() -> Result<()> {
9 let img = image::open("./examples/lena.jpg").unwrap();
10 let escpos_img = EscposImage::new(&img, &Default::default());
11 PrinterConfig::tm_t20ii()
12 .build(io::stdout())?
13 .reset()?
14 .left_margin(100)?
15 .println(format!("Left margin {}: {}", 100, LOREM_IPSUM))?
16 .image(&escpos_img)?
17 .left_margin(200)?
18 .println(format!("Left margin {}: {}", 200, LOREM_IPSUM))?
19 .left_margin(300)?
20 .println(format!("Left margin {}: {}", 300, LOREM_IPSUM))?
21 .reset()?
22 .println(format!("Left margin {}: {}", 0, LOREM_IPSUM))?
23 .cut()?;
24 Ok(())
25}Sourcepub fn justification(
&mut self,
justification: Justification,
) -> Result<&mut Self>
pub fn justification( &mut self, justification: Justification, ) -> Result<&mut Self>
Examples found in repository?
examples/justification.rs (line 14)
6fn main() -> Result<()> {
7 let img = image::open("./examples/lena.jpg").unwrap();
8 let escpos_img = EscposImage::new(&img, ImageOptions::default().scale(0.3)?);
9 PrinterConfig::tm_t20ii()
10 .build(io::stdout())?
11 .reset()?
12 .println("Left: Hello world!")?
13 .image(&escpos_img)?
14 .justification(Justification::Center)?
15 .println("Center: Hello world!")?
16 .image(&escpos_img)?
17 .justification(Justification::Right)?
18 .println("Right: Hello world!")?
19 .image(&escpos_img)?
20 .cut()?;
21 Ok(())
22}Sourcepub fn reset(&mut self) -> Result<&mut Self>
pub fn reset(&mut self) -> Result<&mut Self>
Examples found in repository?
More examples
examples/lena.rs (line 9)
5fn main() -> Result<()> {
6 let img = image::open("./examples/lena.jpg").unwrap();
7 PrinterConfig::tm_t20ii()
8 .build(io::stdout())?
9 .reset()?
10 .println("dithered:")?
11 .image(&EscposImage::new(&img, &Default::default()))?
12 .println("threshold:")?
13 .image(&EscposImage::new(
14 &img,
15 &ImageOptions::default().bit_map_algorithm(BitMapAlgorithm::Threshold(80)),
16 ))?
17 .cut()?;
18 Ok(())
19}examples/justification.rs (line 11)
6fn main() -> Result<()> {
7 let img = image::open("./examples/lena.jpg").unwrap();
8 let escpos_img = EscposImage::new(&img, ImageOptions::default().scale(0.3)?);
9 PrinterConfig::tm_t20ii()
10 .build(io::stdout())?
11 .reset()?
12 .println("Left: Hello world!")?
13 .image(&escpos_img)?
14 .justification(Justification::Center)?
15 .println("Center: Hello world!")?
16 .image(&escpos_img)?
17 .justification(Justification::Right)?
18 .println("Right: Hello world!")?
19 .image(&escpos_img)?
20 .cut()?;
21 Ok(())
22}examples/left_margin.rs (line 13)
8fn main() -> Result<()> {
9 let img = image::open("./examples/lena.jpg").unwrap();
10 let escpos_img = EscposImage::new(&img, &Default::default());
11 PrinterConfig::tm_t20ii()
12 .build(io::stdout())?
13 .reset()?
14 .left_margin(100)?
15 .println(format!("Left margin {}: {}", 100, LOREM_IPSUM))?
16 .image(&escpos_img)?
17 .left_margin(200)?
18 .println(format!("Left margin {}: {}", 200, LOREM_IPSUM))?
19 .left_margin(300)?
20 .println(format!("Left margin {}: {}", 300, LOREM_IPSUM))?
21 .reset()?
22 .println(format!("Left margin {}: {}", 0, LOREM_IPSUM))?
23 .cut()?;
24 Ok(())
25}pub fn print(&mut self, text: impl ToString) -> Result<&mut Self>
Sourcepub fn println(&mut self, text: impl ToString) -> Result<&mut Self>
pub fn println(&mut self, text: impl ToString) -> Result<&mut Self>
Examples found in repository?
More examples
examples/lena.rs (line 10)
5fn main() -> Result<()> {
6 let img = image::open("./examples/lena.jpg").unwrap();
7 PrinterConfig::tm_t20ii()
8 .build(io::stdout())?
9 .reset()?
10 .println("dithered:")?
11 .image(&EscposImage::new(&img, &Default::default()))?
12 .println("threshold:")?
13 .image(&EscposImage::new(
14 &img,
15 &ImageOptions::default().bit_map_algorithm(BitMapAlgorithm::Threshold(80)),
16 ))?
17 .cut()?;
18 Ok(())
19}examples/justification.rs (line 12)
6fn main() -> Result<()> {
7 let img = image::open("./examples/lena.jpg").unwrap();
8 let escpos_img = EscposImage::new(&img, ImageOptions::default().scale(0.3)?);
9 PrinterConfig::tm_t20ii()
10 .build(io::stdout())?
11 .reset()?
12 .println("Left: Hello world!")?
13 .image(&escpos_img)?
14 .justification(Justification::Center)?
15 .println("Center: Hello world!")?
16 .image(&escpos_img)?
17 .justification(Justification::Right)?
18 .println("Right: Hello world!")?
19 .image(&escpos_img)?
20 .cut()?;
21 Ok(())
22}examples/left_margin.rs (line 15)
8fn main() -> Result<()> {
9 let img = image::open("./examples/lena.jpg").unwrap();
10 let escpos_img = EscposImage::new(&img, &Default::default());
11 PrinterConfig::tm_t20ii()
12 .build(io::stdout())?
13 .reset()?
14 .left_margin(100)?
15 .println(format!("Left margin {}: {}", 100, LOREM_IPSUM))?
16 .image(&escpos_img)?
17 .left_margin(200)?
18 .println(format!("Left margin {}: {}", 200, LOREM_IPSUM))?
19 .left_margin(300)?
20 .println(format!("Left margin {}: {}", 300, LOREM_IPSUM))?
21 .reset()?
22 .println(format!("Left margin {}: {}", 0, LOREM_IPSUM))?
23 .cut()?;
24 Ok(())
25}Sourcepub fn feed_lines(&mut self, lines: usize) -> Result<&mut Self>
pub fn feed_lines(&mut self, lines: usize) -> Result<&mut Self>
pub fn feed_paper(&mut self, units: usize) -> Result<&mut Self>
pub fn char_spacing(&mut self, char_spacing: usize) -> Result<&mut Self>
pub fn line_spacing(&mut self, line_spacing: Option<usize>) -> Result<&mut Self>
pub fn command(&mut self, cmd: &Command) -> Result<&mut Self>
Sourcepub fn image(&mut self, image: &EscposImage) -> Result<&mut Self>
pub fn image(&mut self, image: &EscposImage) -> Result<&mut Self>
Examples found in repository?
examples/lena.rs (line 11)
5fn main() -> Result<()> {
6 let img = image::open("./examples/lena.jpg").unwrap();
7 PrinterConfig::tm_t20ii()
8 .build(io::stdout())?
9 .reset()?
10 .println("dithered:")?
11 .image(&EscposImage::new(&img, &Default::default()))?
12 .println("threshold:")?
13 .image(&EscposImage::new(
14 &img,
15 &ImageOptions::default().bit_map_algorithm(BitMapAlgorithm::Threshold(80)),
16 ))?
17 .cut()?;
18 Ok(())
19}More examples
examples/justification.rs (line 13)
6fn main() -> Result<()> {
7 let img = image::open("./examples/lena.jpg").unwrap();
8 let escpos_img = EscposImage::new(&img, ImageOptions::default().scale(0.3)?);
9 PrinterConfig::tm_t20ii()
10 .build(io::stdout())?
11 .reset()?
12 .println("Left: Hello world!")?
13 .image(&escpos_img)?
14 .justification(Justification::Center)?
15 .println("Center: Hello world!")?
16 .image(&escpos_img)?
17 .justification(Justification::Right)?
18 .println("Right: Hello world!")?
19 .image(&escpos_img)?
20 .cut()?;
21 Ok(())
22}examples/left_margin.rs (line 16)
8fn main() -> Result<()> {
9 let img = image::open("./examples/lena.jpg").unwrap();
10 let escpos_img = EscposImage::new(&img, &Default::default());
11 PrinterConfig::tm_t20ii()
12 .build(io::stdout())?
13 .reset()?
14 .left_margin(100)?
15 .println(format!("Left margin {}: {}", 100, LOREM_IPSUM))?
16 .image(&escpos_img)?
17 .left_margin(200)?
18 .println(format!("Left margin {}: {}", 200, LOREM_IPSUM))?
19 .left_margin(300)?
20 .println(format!("Left margin {}: {}", 300, LOREM_IPSUM))?
21 .reset()?
22 .println(format!("Left margin {}: {}", 0, LOREM_IPSUM))?
23 .cut()?;
24 Ok(())
25}pub unsafe fn raw(&mut self, data: impl AsRef<[u8]>) -> Result<&mut Self>
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for Printer<D>where
D: Freeze,
impl<D> RefUnwindSafe for Printer<D>where
D: RefUnwindSafe,
impl<D> Send for Printer<D>where
D: Send,
impl<D> Sync for Printer<D>where
D: Sync,
impl<D> Unpin for Printer<D>where
D: Unpin,
impl<D> UnwindSafe for Printer<D>where
D: UnwindSafe,
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
Mutably borrows from an owned value. Read more