rust_texas/component/
image.rs1use crate::prelude::*;
2
3#[derive(Debug, Clone)]
6pub struct Image {
7 path: String,
8 opt: Vec<String>,
9}
10impl AsLatex for Image {
11 fn to_string(&self) -> String {
12 let options = self
13 .opt
14 .iter()
15 .map(|s| format!("{}, ", s))
16 .collect::<String>();
17 format!("\\includegraphics[{}]{{{}}} \n", options, self.path)
18 }
19}
20impl Opt for Image {
21 fn add_option(&mut self, opt: &str) {
22 self.opt.push(opt.to_string());
23 }
24}
25impl Image {
26 pub fn new(path: &str) -> Self {
27 Self {
28 path: path.to_string(),
29 opt: vec![],
30 }
31 }
32
33 pub fn with_options(path: &str, opt: Vec<String>) -> Self {
34 Self {
35 path: path.to_string(),
36 opt,
37 }
38 }
39}