use serde_json::{Value, json};
use super::VtaClient;
use crate::error::VtaError;
use crate::trust_tasks;
const MEMORY_TT_TIMEOUT: u64 = 30;
impl VtaClient {
pub async fn memory_put(
&self,
context_id: &str,
key: &str,
value: &str,
) -> Result<Value, VtaError> {
let payload = json!({
"contextId": context_id,
"key": key,
"value": value,
});
self.dispatch_trust_task(
trust_tasks::TASK_VTA_MEMORY_PUT_0_1,
payload,
MEMORY_TT_TIMEOUT,
)
.await
}
pub async fn memory_list(&self, context_id: &str) -> Result<Value, VtaError> {
let payload = json!({ "contextId": context_id });
self.dispatch_trust_task(
trust_tasks::TASK_VTA_MEMORY_LIST_0_1,
payload,
MEMORY_TT_TIMEOUT,
)
.await
}
pub async fn memory_delete(&self, context_id: &str, key: &str) -> Result<Value, VtaError> {
let payload = json!({
"contextId": context_id,
"key": key,
});
self.dispatch_trust_task(
trust_tasks::TASK_VTA_MEMORY_DELETE_0_1,
payload,
MEMORY_TT_TIMEOUT,
)
.await
}
}