1- use crate :: Error :: { PoisonedLock , UnsupportedNamespace } ;
1+ use crate :: Error :: UnsupportedNamespace ;
22use crate :: Result ;
33use crate :: repository:: model:: Repository ;
44#[ cfg( feature = "portal-corp" ) ]
@@ -44,9 +44,7 @@ impl RepositoryRegistry {
4444 let Some ( new_fn) = self . repositories . get ( & namespace) else {
4545 return Err ( UnsupportedNamespace ( namespace. to_string ( ) ) ) ;
4646 } ;
47- let new_function = new_fn
48- . read ( )
49- . map_err ( |error| PoisonedLock ( error. to_string ( ) ) ) ?;
47+ let new_function = new_fn. read ( ) ?;
5048 new_function ( )
5149 }
5250}
@@ -79,10 +77,7 @@ impl Default for RepositoryRegistry {
7977/// # Errors
8078/// * If the registry is poisoned.
8179pub fn register ( namespace : & str , new_fn : Box < NewFn > ) -> Result < ( ) > {
82- let mut registry = REGISTRY
83- . lock ( )
84- . map_err ( |error| PoisonedLock ( error. to_string ( ) ) ) ?;
85- registry. register ( namespace, new_fn) ;
80+ REGISTRY . lock ( ) ?. register ( namespace, new_fn) ;
8681 Ok ( ( ) )
8782}
8883
@@ -91,21 +86,15 @@ pub fn register(namespace: &str, new_fn: Box<NewFn>) -> Result<()> {
9186/// # Errors
9287/// * If the namespace is not supported.
9388pub fn get ( namespace : & str ) -> Result < Box < dyn Repository > > {
94- let registry = REGISTRY
95- . lock ( )
96- . map_err ( |error| PoisonedLock ( error. to_string ( ) ) ) ?;
97- registry. get ( namespace)
89+ REGISTRY . lock ( ) ?. get ( namespace)
9890}
9991
10092/// Gets the namespaces of the registered repositories.
10193///
10294/// # Errors
10395/// * If the registry is poisoned.
10496pub fn get_namespaces ( ) -> Result < Vec < String > > {
105- let registry = REGISTRY
106- . lock ( )
107- . map_err ( |error| PoisonedLock ( error. to_string ( ) ) ) ?;
108- Ok ( registry. repositories . keys ( ) . cloned ( ) . collect ( ) )
97+ Ok ( REGISTRY . lock ( ) ?. repositories . keys ( ) . cloned ( ) . collect ( ) )
10998}
11099
111100/// Gets all the registered repositories.
0 commit comments