mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
update base64 crate
This commit is contained in:
parent
2c679759dc
commit
e1600b0ebe
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -45,9 +45,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.1"
|
version = "0.21.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bencher"
|
name = "bencher"
|
||||||
|
@ -26,7 +26,7 @@ simple-error = "0.2.0"
|
|||||||
serde_yaml = "0.8.17"
|
serde_yaml = "0.8.17"
|
||||||
toml = "~0.5.8"
|
toml = "~0.5.8"
|
||||||
xml-rs = "0.8.0"
|
xml-rs = "0.8.0"
|
||||||
base64 = "0.13.0"
|
base64 = "0.21.0"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
dirs = "4.0.0"
|
dirs = "4.0.0"
|
||||||
unicode-segmentation = "1.2.1"
|
unicode-segmentation = "1.2.1"
|
||||||
|
@ -2,7 +2,8 @@ use std::error::Error;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
use base64::{encode, encode_config, URL_SAFE};
|
use base64::Engine;
|
||||||
|
use base64::{engine::general_purpose::STANDARD, engine::general_purpose::URL_SAFE};
|
||||||
|
|
||||||
use crate::build::Val;
|
use crate::build::Val;
|
||||||
use crate::convert::traits::Importer;
|
use crate::convert::traits::Importer;
|
||||||
@ -14,9 +15,9 @@ pub struct Base64Importer {
|
|||||||
impl Importer for Base64Importer {
|
impl Importer for Base64Importer {
|
||||||
fn import(&self, bytes: &[u8]) -> Result<Rc<Val>, Box<dyn Error>> {
|
fn import(&self, bytes: &[u8]) -> Result<Rc<Val>, Box<dyn Error>> {
|
||||||
return if self.url_safe {
|
return if self.url_safe {
|
||||||
Ok(Rc::new(Val::Str(encode(bytes))))
|
Ok(Rc::new(Val::Str(STANDARD.encode(bytes))))
|
||||||
} else {
|
} else {
|
||||||
Ok(Rc::new(Val::Str(encode_config(bytes, URL_SAFE))))
|
Ok(Rc::new(Val::Str(URL_SAFE.encode(bytes))))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user