Skip to content

Commit c82b5a5

Browse files
committed
Fix rust
1 parent 11197d8 commit c82b5a5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

clients/redis/rust/src/lib.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,26 @@ pub struct Hide;
2424

2525
#[derive(Clone)]
2626
pub enum Value {
27-
String { value: String },
28-
EnvVariable { name: String, value: Option<String> },
27+
String {
28+
value: &'static str,
29+
},
30+
EnvVariable {
31+
name: &'static str,
32+
value: Option<String>,
33+
},
2934
}
3035

3136
impl Value {
32-
pub fn from_string(value: String) -> Self {
37+
pub fn from_string(value: &'static str) -> Self {
3338
Self::String { value }
3439
}
35-
pub fn from_env_variable(name: String) -> Self {
40+
pub fn from_env_variable(name: &'static str) -> Self {
3641
let value = std::env::var(&name).ok();
3742
Self::EnvVariable { name, value }
3843
}
3944
fn require(&self) -> Result<String, Box<dyn std::error::Error + Sync + Send>> {
4045
match self {
41-
Self::String { value } => Ok(value.clone()),
46+
Self::String { value } => Ok((*value).to_string()),
4247
Self::EnvVariable { name, value } => Ok(value
4348
.clone()
4449
.ok_or(format!("Environment variable \"{name}\" is not set"))?),
@@ -115,10 +120,10 @@ pub struct MemorixBase {
115120

116121
impl MemorixBase {
117122
pub async fn new(
118-
redis_url: &str,
123+
redis_url: &Value,
119124
namespace_name_tree: &'static [&'static str],
120125
) -> Result<MemorixBase, Box<dyn std::error::Error + Sync + Send>> {
121-
let client = redis::Client::open(redis_url)?;
126+
let client = redis::Client::open(redis_url.require()?)?;
122127
let redis = client.get_multiplexed_async_connection().await?;
123128
let task_redis = client.get_multiplexed_async_connection().await?;
124129
Ok(Self {

0 commit comments

Comments
 (0)