parsers: Bump base64
Version 0.21 replaced base64::decode() with an Engine trait and multiple structs implementing it for various alphabets, various performance profiles, etc. It is slightly longer to import but in the end does the very same thing.
This commit is contained in:
parent
3ad616945a
commit
2955a0fe60
6 changed files with 44 additions and 23 deletions
|
|
@ -5,6 +5,7 @@
|
|||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use crate::util::error::Error;
|
||||
use base64::{engine::general_purpose::STANDARD as Base64Engine, Engine};
|
||||
use jid::Jid;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
|
@ -58,11 +59,11 @@ pub struct Base64;
|
|||
|
||||
impl Base64 {
|
||||
pub fn decode(s: &str) -> Result<Vec<u8>, Error> {
|
||||
Ok(base64::decode(s)?)
|
||||
Ok(Base64Engine.decode(s)?)
|
||||
}
|
||||
|
||||
pub fn encode(b: &[u8]) -> Option<String> {
|
||||
Some(base64::encode(b))
|
||||
Some(Base64Engine.encode(b))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,11 +76,11 @@ impl WhitespaceAwareBase64 {
|
|||
.chars()
|
||||
.filter(|ch| *ch != ' ' && *ch != '\n' && *ch != '\t')
|
||||
.collect();
|
||||
Ok(base64::decode(&s)?)
|
||||
Ok(Base64Engine.decode(&s)?)
|
||||
}
|
||||
|
||||
pub fn encode(b: &[u8]) -> Option<String> {
|
||||
Some(base64::encode(b))
|
||||
Some(Base64Engine.encode(b))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue