aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-26 16:20:41 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-26 16:20:41 +0100
commit94d559ae00bdb899c4463667a9d950b27e5bb23c (patch)
treea734a4d05cbedfaaff4f3bf63a0b659499b797bb /src/api/k2v
parentc7d0ad0aa0e492b913c5dda8ff1a7ad5a579fb3a (diff)
parent5fb383fe4c248181e27df12a57849886e50bacb7 (diff)
downloadgarage-94d559ae00bdb899c4463667a9d950b27e5bb23c.tar.gz
garage-94d559ae00bdb899c4463667a9d950b27e5bb23c.zip
Merge branch 'main' into report-disk-usage
Diffstat (limited to 'src/api/k2v')
-rw-r--r--src/api/k2v/batch.rs11
-rw-r--r--src/api/k2v/item.rs3
2 files changed, 9 insertions, 5 deletions
diff --git a/src/api/k2v/batch.rs b/src/api/k2v/batch.rs
index 78035362..82b4f7e3 100644
--- a/src/api/k2v/batch.rs
+++ b/src/api/k2v/batch.rs
@@ -1,5 +1,6 @@
use std::sync::Arc;
+use base64::prelude::*;
use hyper::{Body, Request, Response, StatusCode};
use serde::{Deserialize, Serialize};
@@ -31,9 +32,11 @@ pub async fn handle_insert_batch(
.transpose()
.ok_or_bad_request("Invalid causality token")?;
let v = match it.v {
- Some(vs) => {
- DvvsValue::Value(base64::decode(vs).ok_or_bad_request("Invalid base64 value")?)
- }
+ Some(vs) => DvvsValue::Value(
+ BASE64_STANDARD
+ .decode(vs)
+ .ok_or_bad_request("Invalid base64 value")?,
+ ),
None => DvvsValue::Deleted,
};
items2.push((it.pk, it.sk, ct, v));
@@ -322,7 +325,7 @@ impl ReadBatchResponseItem {
.values()
.iter()
.map(|v| match v {
- DvvsValue::Value(x) => Some(base64::encode(x)),
+ DvvsValue::Value(x) => Some(BASE64_STANDARD.encode(x)),
DvvsValue::Deleted => None,
})
.collect::<Vec<_>>();
diff --git a/src/api/k2v/item.rs b/src/api/k2v/item.rs
index f85138c7..041382c0 100644
--- a/src/api/k2v/item.rs
+++ b/src/api/k2v/item.rs
@@ -1,5 +1,6 @@
use std::sync::Arc;
+use base64::prelude::*;
use http::header;
use hyper::{Body, Request, Response, StatusCode};
@@ -81,7 +82,7 @@ impl ReturnFormat {
.iter()
.map(|v| match v {
DvvsValue::Deleted => serde_json::Value::Null,
- DvvsValue::Value(v) => serde_json::Value::String(base64::encode(v)),
+ DvvsValue::Value(v) => serde_json::Value::String(BASE64_STANDARD.encode(v)),
})
.collect::<Vec<_>>();
let json_body =