File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1010#![ allow( clippy:: mutable_key_type) ] // TODO: remove when possible. Needed to suppress false positive for async_trait
1111
1212use std:: borrow:: Cow ;
13+ use std:: io:: { Error , ErrorKind } ;
1314use std:: ops:: { Deref , DerefMut } ;
15+ use std:: path:: Path ;
1416
1517pub extern crate nostr;
1618pub extern crate nostr_database as database;
@@ -35,10 +37,14 @@ impl NdbDatabase {
3537 /// Open nostrdb
3638 pub fn open < P > ( path : P ) -> Result < Self , DatabaseError >
3739 where
38- P : AsRef < str > ,
40+ P : AsRef < Path > ,
3941 {
40- let path: & str = path. as_ref ( ) ;
41- let config = Config :: new ( ) ;
42+ let path: & Path = path. as_ref ( ) ;
43+ let path: & str = path. to_str ( ) . ok_or_else ( || {
44+ DatabaseError :: backend ( Error :: new ( ErrorKind :: InvalidInput , "path is not valid " ) )
45+ } ) ?;
46+
47+ let config: Config = Config :: new ( ) ;
4248
4349 Ok ( Self {
4450 db : Ndb :: new ( path, & config) . map_err ( DatabaseError :: backend) ?,
You can’t perform that action at this time.
0 commit comments