K2V #293
1 changed files with 3 additions and 2 deletions
|
@ -42,11 +42,12 @@ impl CausalContext {
|
||||||
bytes.extend(u64::to_be_bytes(i));
|
bytes.extend(u64::to_be_bytes(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
base64::encode(bytes)
|
base64::encode_config(bytes, base64::URL_SAFE_NO_PAD)
|
||||||
}
|
}
|
||||||
/// Parse from base64-encoded binary representation
|
/// Parse from base64-encoded binary representation
|
||||||
pub fn parse(s: &str) -> Result<Self, Error> {
|
pub fn parse(s: &str) -> Result<Self, Error> {
|
||||||
let bytes = base64::decode(s).ok_or_message("Invalid causality token (bad base64)")?;
|
let bytes = base64::decode_config(s, base64::URL_SAFE_NO_PAD)
|
||||||
|
.ok_or_message("Invalid causality token (bad base64)")?;
|
||||||
if bytes.len() % 16 != 8 || bytes.len() < 8 {
|
if bytes.len() % 16 != 8 || bytes.len() < 8 {
|
||||||
return Err(Error::Message(
|
return Err(Error::Message(
|
||||||
"Invalid causality token (bad length)".into(),
|
"Invalid causality token (bad length)".into(),
|
||||||
|
|
Loading…
Reference in a new issue