Browse Source

Decoding base64

master
Julio Biason 5 years ago
parent
commit
bac6e65fba
  1. 16
      Cargo.lock
  2. 3
      Cargo.toml
  3. 15
      src/main.rs

16
Cargo.lock generated

@ -3,6 +3,19 @@ name = "RustyXML"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "base64"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "byteorder"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "deunicode"
version = "0.4.3"
@ -13,6 +26,7 @@ name = "enexparser"
version = "0.1.0"
dependencies = [
"RustyXML 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -26,5 +40,7 @@ dependencies = [
[metadata]
"checksum RustyXML 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9222d58bccd9e6e3b82098a2ec142ad34e5d433de986d46cec03ad3a2b5fd529"
"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690"
"checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373"

3
Cargo.toml

@ -6,4 +6,5 @@ edition = "2018"
[dependencies]
RustyXML = "0.1.1"
slug = "0.1.4"
slug = "0.1.4"
base64 = "0.10.1"

15
src/main.rs

@ -5,6 +5,7 @@ use std::io::prelude::*;
use std::path::Path;
use std::vec::Vec;
use slug::slugify;
use base64::decode;
#[derive(Debug)]
enum CurrentTag {
@ -49,10 +50,10 @@ impl State {
..self }
}
pub fn remove_tag(self) -> Self {
Self { tag: None,
..self }
}
// pub fn remove_tag(self) -> Self {
// Self { tag: None,
// ..self }
// }
}
fn create_note_storage(title: &str) -> String {
@ -76,9 +77,13 @@ fn open_tag(current_state: State, tag: &str) -> State {
fn dump_resource(current_state: State) -> State {
let unnamed = String::from("content");
Path::new("data")
let content_storage = Path::new("data")
.join(current_state.title.as_ref().unwrap())
.join(current_state.filename.as_ref().unwrap_or(&unnamed));
let content = base64::decode(&current_state.data).unwrap();
let mut target = File::create(content_storage).unwrap();
target.write_all(&content).unwrap();
current_state
}

Loading…
Cancel
Save