feat: add svg and png export (#101)

This commit is contained in:
Myriad-Dreamin 2024-03-26 11:25:46 +08:00 committed by GitHub
parent e649ad308f
commit 413c2e8deb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 298 additions and 136 deletions

View file

@ -109,12 +109,40 @@ pub trait StatefulRequest {
#[allow(missing_docs)]
mod polymorphic {
use serde::{Deserialize, Serialize};
use super::prelude::*;
use super::*;
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum PageSelection {
#[serde(rename = "first")]
First,
#[serde(rename = "merged")]
Merged,
}
#[derive(Debug, Clone)]
pub enum ExportKind {
Pdf,
Svg { page: PageSelection },
Png { page: PageSelection },
}
impl ExportKind {
pub fn extension(&self) -> &str {
match self {
Self::Pdf => "pdf",
Self::Svg { .. } => "svg",
Self::Png { .. } => "png",
}
}
}
#[derive(Debug, Clone)]
pub struct OnExportRequest {
pub path: PathBuf,
pub kind: ExportKind,
}
#[derive(Debug, Clone)]