@@ -24,21 +24,26 @@ pub struct Hide;
24
24
25
25
#[ derive( Clone ) ]
26
26
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
+ } ,
29
34
}
30
35
31
36
impl Value {
32
- pub fn from_string ( value : String ) -> Self {
37
+ pub fn from_string ( value : & ' static str ) -> Self {
33
38
Self :: String { value }
34
39
}
35
- pub fn from_env_variable ( name : String ) -> Self {
40
+ pub fn from_env_variable ( name : & ' static str ) -> Self {
36
41
let value = std:: env:: var ( & name) . ok ( ) ;
37
42
Self :: EnvVariable { name, value }
38
43
}
39
44
fn require ( & self ) -> Result < String , Box < dyn std:: error:: Error + Sync + Send > > {
40
45
match self {
41
- Self :: String { value } => Ok ( value. clone ( ) ) ,
46
+ Self :: String { value } => Ok ( ( * value) . to_string ( ) ) ,
42
47
Self :: EnvVariable { name, value } => Ok ( value
43
48
. clone ( )
44
49
. ok_or ( format ! ( "Environment variable \" {name}\" is not set" ) ) ?) ,
@@ -115,10 +120,10 @@ pub struct MemorixBase {
115
120
116
121
impl MemorixBase {
117
122
pub async fn new (
118
- redis_url : & str ,
123
+ redis_url : & Value ,
119
124
namespace_name_tree : & ' static [ & ' static str ] ,
120
125
) -> 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 ( ) ? ) ?;
122
127
let redis = client. get_multiplexed_async_connection ( ) . await ?;
123
128
let task_redis = client. get_multiplexed_async_connection ( ) . await ?;
124
129
Ok ( Self {
0 commit comments