From 0660151a8b641fa0a23dde2598132029970f7ae4 Mon Sep 17 00:00:00 2001 From: jelemux Date: Thu, 11 Feb 2021 12:07:22 +0100 Subject: refactoring - reduced code size by about a third --- src/viewmodel/utility.rs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/viewmodel/utility.rs (limited to 'src/viewmodel/utility.rs') diff --git a/src/viewmodel/utility.rs b/src/viewmodel/utility.rs deleted file mode 100644 index 617ee45..0000000 --- a/src/viewmodel/utility.rs +++ /dev/null @@ -1,45 +0,0 @@ -#[derive(Clone)] -pub struct Download { - pub file_name: String, - pub content: String, - pub mime_type: MimeType, -} - -impl Download { - pub fn as_data_link(&self) -> String { - let data = base64::encode(&*self.content); - let uri_component: String = js_sys::encode_uri_component(&data).into(); - - format!("data:{};base64,{}", self.mime_type.as_text(), uri_component) - } -} - -#[derive(Clone, Copy)] -pub enum MimeType { - PDF, - VCard, - SVG, -} - -impl MimeType { - pub fn as_text(&self) -> &str { - match self { - MimeType::PDF => "application/pdf", - MimeType::VCard => "text/vcard", - MimeType::SVG => "image/svg+xml", - } - } -} - -#[derive(Clone, Copy, PartialEq)] -pub enum DownloadOption { - PDF, - VCard, - QrCode, -} - -#[derive(Clone, Debug, PartialEq)] -pub struct File { - pub name: String, - pub content: String, -} -- cgit v1.2.3