diff --git a/packages/ciphernode/data/src/data_store.rs b/packages/ciphernode/data/src/data_store.rs index 84dede64..7a15cdff 100644 --- a/packages/ciphernode/data/src/data_store.rs +++ b/packages/ciphernode/data/src/data_store.rs @@ -1,3 +1,5 @@ +use std::borrow::Cow; + use crate::{InMemStore, IntoKey, SledStore}; use actix::{Addr, Message, Recipient}; use anyhow::Result; @@ -58,7 +60,7 @@ impl DataStore { /// Writes data to the scope location pub fn write(&self, value: T) { let Ok(serialized) = bincode::serialize(&value) else { - let str_key = self.get_scope().unwrap_or("".to_string()); + let str_key = self.get_scope().unwrap_or(Cow::Borrowed("")); let str_error = format!("Could not serialize value passed to {}", str_key); error!(str_error); return; @@ -68,8 +70,8 @@ impl DataStore { } /// Get the scope as a string - pub fn get_scope(&self) -> Result { - Ok(String::from_utf8(self.scope.clone())?) + pub fn get_scope(&self) -> Result> { + Ok(String::from_utf8_lossy(&self.scope)) } /// Changes the scope for the data store.