summaryrefslogtreecommitdiff
path: root/subplotlib
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2023-04-10 11:47:34 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2023-04-10 11:47:34 +0100
commitacf390c47f2b23a460e6eb507447809b29eeb3a1 (patch)
tree9ae8e3a6a6f68e6f626f2ee5a9ae80d6171d1fbf /subplotlib
parent321eaa952ebd9c445745ea811f54598baf29e74e (diff)
downloadsubplot-acf390c47f2b23a460e6eb507447809b29eeb3a1.tar.gz
(chore): Update for newer base64 API
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib')
-rw-r--r--subplotlib/src/file.rs12
-rw-r--r--subplotlib/src/utils.rs4
2 files changed, 12 insertions, 4 deletions
diff --git a/subplotlib/src/file.rs b/subplotlib/src/file.rs
index 84f3495..c1c9afe 100644
--- a/subplotlib/src/file.rs
+++ b/subplotlib/src/file.rs
@@ -7,7 +7,8 @@
use std::path::{Path, PathBuf};
use std::sync::Arc;
-use base64::decode;
+use base64::prelude::{Engine as _, BASE64_STANDARD};
+
/// An embedded data file.
///
/// Embedded data files have names and content. The subplot template will generate
@@ -82,11 +83,16 @@ impl SubplotDataFile {
///
/// This will panic if the passed in strings are not correctly base64 encoded.
pub fn new(name: &str, data: &str) -> Self {
- let name = decode(name).expect("Subplot generated bad base64?");
+ let name = BASE64_STANDARD
+ .decode(name)
+ .expect("Subplot generated bad base64?");
let name = String::from_utf8_lossy(&name);
let name: PathBuf = name.as_ref().into();
let name = name.into();
- let data = decode(data).expect("Subplot generated bad base64?").into();
+ let data = BASE64_STANDARD
+ .decode(data)
+ .expect("Subplot generated bad base64?")
+ .into();
Self { name, data }
}
diff --git a/subplotlib/src/utils.rs b/subplotlib/src/utils.rs
index 642848a..25a9360 100644
--- a/subplotlib/src/utils.rs
+++ b/subplotlib/src/utils.rs
@@ -1,5 +1,7 @@
//! Utility functions used by subplotlib or the generated test functions
+use base64::prelude::{Engine as _, BASE64_STANDARD};
+
/// Decode a base64 string.
///
/// If the result is not a valid utf8 string then it is lossily coerced.
@@ -14,6 +16,6 @@
///
/// Will panic if it's not valid base64 leading to a string.
pub fn base64_decode(input: &str) -> String {
- let dec = base64::decode(input).expect("bad base64");
+ let dec = BASE64_STANDARD.decode(input).expect("bad base64");
String::from_utf8_lossy(&dec).to_string()
}