Remove Test command

This commit is contained in:
Joscha 2024-03-30 12:25:52 +01:00
parent 9b1df02819
commit dddef6b3b5
2 changed files with 0 additions and 39 deletions

View file

@ -32,7 +32,6 @@ pub struct BoxedDrawing(Box<dyn Drawing + Send>);
pub enum Command { pub enum Command {
Draw(BoxedDrawing), Draw(BoxedDrawing),
Test,
Text(String), Text(String),
Image { image: RgbaImage, bright: bool }, Image { image: RgbaImage, bright: bool },
Photo { image: RgbaImage, title: String }, Photo { image: RgbaImage, title: String },
@ -79,7 +78,6 @@ impl Drawer {
match command { match command {
Command::Draw(drawing) => drawing.0.draw(&mut self.printer, &mut self.ctx)?, Command::Draw(drawing) => drawing.0.draw(&mut self.printer, &mut self.ctx)?,
Command::Test => self.on_test()?,
Command::Text(text) => self.on_text(text)?, Command::Text(text) => self.on_text(text)?,
Command::Image { image, bright } => self.on_image(image, bright)?, Command::Image { image, bright } => self.on_image(image, bright)?,
Command::Photo { image, title } => self.on_photo(image, title)?, Command::Photo { image, title } => self.on_photo(image, title)?,
@ -90,38 +88,6 @@ impl Drawer {
Ok(()) Ok(())
} }
fn on_test(&mut self) -> anyhow::Result<()> {
let mut tree = Tree::<Context>::new(WHITE);
let text = Text::new()
.with_metrics(Text::default_metrics().scale(2.0))
.and_plain("Hello\nworld!")
.widget(&mut self.ctx.font_stuff)
.node()
.with_margin_horiz(length(8.0))
.with_margin_vert(length(2.0))
.register(&mut tree)?;
let wrap = Block::new()
.with_border(BLACK)
.node()
.with_border_all(length(2.0))
.and_child(text)
.register(&mut tree)?;
let root = Block::new()
.with_border(BLACK)
.node()
.with_size_width(percent(1.0))
.with_border_all(length(2.0))
.with_padding_all(length(10.0))
.and_child(wrap)
.register(&mut tree)?;
self.printer.print_tree(&mut tree, &mut self.ctx, root)?;
Ok(())
}
fn on_text(&mut self, text: String) -> anyhow::Result<()> { fn on_text(&mut self, text: String) -> anyhow::Result<()> {
let mut tree = Tree::<Context>::new(WHITE); let mut tree = Tree::<Context>::new(WHITE);

View file

@ -23,7 +23,6 @@ struct Server {
pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()> { pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()> {
let app = Router::new() let app = Router::new()
.route("/test", post(post_test))
.route("/text", post(post_text)) .route("/text", post(post_text))
.route("/image", post(post_image).fallback(get_static_file)) .route("/image", post(post_image).fallback(get_static_file))
.route("/photo", post(post_photo).fallback(get_static_file)) .route("/photo", post(post_photo).fallback(get_static_file))
@ -39,10 +38,6 @@ pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()>
Ok(()) Ok(())
} }
async fn post_test(server: State<Server>) {
let _ = server.tx.send(Command::Test).await;
}
#[derive(Deserialize)] #[derive(Deserialize)]
struct PostTextForm { struct PostTextForm {
text: String, text: String,