Printer

Struct Printer 

Source
pub struct Printer<D> { /* private fields */ }

Implementations§

Source§

impl<D> Printer<D>
where D: PrinterDevice,

Source

pub fn markdown<'a, I>( &mut self, iter: I, opts: &MarkdownRenderOptions, ) -> Result<&mut Self>
where I: Iterator<Item = Event<'a>>,

Examples found in repository?
examples/simple_markdown.rs (line 9)
4fn main() -> Result<()> {
5    let parser = MarkdownParser::new("Hello, World!");
6    PrinterConfig::tm_t20ii()
7        .build(io::stdout())?
8        .reset()?
9        .markdown(parser, &Default::default())?
10        .cut()?;
11    Ok(())
12}
More examples
Hide additional examples
examples/markdown.rs (line 70)
63fn main() -> Result<()> {
64    let mut options = MarkdownParserOptions::empty();
65    options.insert(MarkdownParserOptions::ENABLE_STRIKETHROUGH);
66    let parser = MarkdownParser::new_ext(TEST_MD, options);
67    PrinterConfig::tm_t20ii()
68        .build(io::stdout())?
69        .reset()?
70        .markdown(parser, &Default::default())?
71        .cut()?;
72    Ok(())
73}
Source§

impl<D> Printer<D>

Source

pub fn builder() -> PrinterConfig

Source

pub fn new(device: D, config: PrinterConfig) -> Result<Self>

Source§

impl<D> Printer<D>
where D: PrinterDevice,

Source

pub fn cut(&mut self) -> Result<&mut Self>

Examples found in repository?
examples/hello_world.rs (line 10)
4fn main() -> Result<()> {
5    PrinterConfig::tm_t20ii()
6        .build(io::stdout())?
7        .reset()?
8        .println("Hello world!")?
9        .feed_lines(5)?
10        .cut()?;
11    Ok(())
12}
More examples
Hide additional examples
examples/simple_markdown.rs (line 10)
4fn main() -> Result<()> {
5    let parser = MarkdownParser::new("Hello, World!");
6    PrinterConfig::tm_t20ii()
7        .build(io::stdout())?
8        .reset()?
9        .markdown(parser, &Default::default())?
10        .cut()?;
11    Ok(())
12}
examples/markdown.rs (line 71)
63fn main() -> Result<()> {
64    let mut options = MarkdownParserOptions::empty();
65    options.insert(MarkdownParserOptions::ENABLE_STRIKETHROUGH);
66    let parser = MarkdownParser::new_ext(TEST_MD, options);
67    PrinterConfig::tm_t20ii()
68        .build(io::stdout())?
69        .reset()?
70        .markdown(parser, &Default::default())?
71        .cut()?;
72    Ok(())
73}
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}
Source

pub fn init(&mut self) -> Result<&mut Self>

Source

pub fn print_mode_default(&mut self) -> Result<&mut Self>

Source

pub fn charset(&mut self, charset: Charset) -> Result<&mut Self>

Source

pub fn code_table(&mut self, code_table: CodeTable) -> Result<&mut Self>

Source

pub fn font(&mut self, font: Font) -> Result<&mut Self>

Source

pub fn underline(&mut self, thickness: UnderlineThickness) -> Result<&mut Self>

Source

pub fn bold(&mut self, enabled: bool) -> Result<&mut Self>

Source

pub fn double_strike(&mut self, enabled: bool) -> Result<&mut Self>

Source

pub fn white_black_reverse(&mut self, enabled: bool) -> Result<&mut Self>

Source

pub fn char_size( &mut self, magnification: CharMagnification, ) -> Result<&mut Self>

Source

pub fn split_words(&mut self, enabled: bool) -> Result<&mut Self>

Source

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}
Source

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}
Source

pub fn reset(&mut self) -> Result<&mut Self>

Examples found in repository?
examples/hello_world.rs (line 7)
4fn main() -> Result<()> {
5    PrinterConfig::tm_t20ii()
6        .build(io::stdout())?
7        .reset()?
8        .println("Hello world!")?
9        .feed_lines(5)?
10        .cut()?;
11    Ok(())
12}
More examples
Hide additional examples
examples/simple_markdown.rs (line 8)
4fn main() -> Result<()> {
5    let parser = MarkdownParser::new("Hello, World!");
6    PrinterConfig::tm_t20ii()
7        .build(io::stdout())?
8        .reset()?
9        .markdown(parser, &Default::default())?
10        .cut()?;
11    Ok(())
12}
examples/markdown.rs (line 69)
63fn main() -> Result<()> {
64    let mut options = MarkdownParserOptions::empty();
65    options.insert(MarkdownParserOptions::ENABLE_STRIKETHROUGH);
66    let parser = MarkdownParser::new_ext(TEST_MD, options);
67    PrinterConfig::tm_t20ii()
68        .build(io::stdout())?
69        .reset()?
70        .markdown(parser, &Default::default())?
71        .cut()?;
72    Ok(())
73}
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}
Source

pub fn print(&mut self, text: impl ToString) -> Result<&mut Self>

Source

pub fn println(&mut self, text: impl ToString) -> Result<&mut Self>

Examples found in repository?
examples/hello_world.rs (line 8)
4fn main() -> Result<()> {
5    PrinterConfig::tm_t20ii()
6        .build(io::stdout())?
7        .reset()?
8        .println("Hello world!")?
9        .feed_lines(5)?
10        .cut()?;
11    Ok(())
12}
More examples
Hide additional 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}
Source

pub fn feed_lines(&mut self, lines: usize) -> Result<&mut Self>

Examples found in repository?
examples/hello_world.rs (line 9)
4fn main() -> Result<()> {
5    PrinterConfig::tm_t20ii()
6        .build(io::stdout())?
7        .reset()?
8        .println("Hello world!")?
9        .feed_lines(5)?
10        .cut()?;
11    Ok(())
12}
Source

pub fn feed_paper(&mut self, units: usize) -> Result<&mut Self>

Source

pub fn char_spacing(&mut self, char_spacing: usize) -> Result<&mut Self>

Source

pub fn line_spacing(&mut self, line_spacing: Option<usize>) -> Result<&mut Self>

Source

pub fn command(&mut self, cmd: &Command) -> Result<&mut Self>

Source

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
Hide additional 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}
Source

pub unsafe fn raw(&mut self, data: impl AsRef<[u8]>) -> Result<&mut Self>

Trait Implementations§

Source§

impl<D: Clone> Clone for Printer<D>

Source§

fn clone(&self) -> Printer<D>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug> Debug for Printer<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.