1+ use std:: ops:: Deref ;
2+
13use serde:: { Deserialize , Serialize } ;
24use stackable_operator:: {
35 database_connections:: {
@@ -20,8 +22,10 @@ pub enum MetadataDatabaseConnection {
2022 Generic ( GenericSqlAlchemyDatabaseConnection ) ,
2123}
2224
23- impl MetadataDatabaseConnection {
24- pub fn as_sqlalchemy_database_connection ( & self ) -> & dyn SqlAlchemyDatabaseConnection {
25+ impl Deref for MetadataDatabaseConnection {
26+ type Target = dyn SqlAlchemyDatabaseConnection ;
27+
28+ fn deref ( & self ) -> & Self :: Target {
2529 match self {
2630 Self :: Postgresql ( p) => p,
2731 Self :: Generic ( g) => g,
@@ -39,8 +43,10 @@ pub enum CeleryResultBackendConnection {
3943 Generic ( GenericCeleryDatabaseConnection ) ,
4044}
4145
42- impl CeleryResultBackendConnection {
43- pub fn as_celery_database_connection ( & self ) -> & dyn CeleryDatabaseConnection {
46+ impl Deref for CeleryResultBackendConnection {
47+ type Target = dyn CeleryDatabaseConnection ;
48+
49+ fn deref ( & self ) -> & Self :: Target {
4450 match self {
4551 Self :: Postgresql ( p) => p,
4652 Self :: Generic ( g) => g,
@@ -58,8 +64,10 @@ pub enum CeleryBrokerConnection {
5864 Generic ( GenericCeleryDatabaseConnection ) ,
5965}
6066
61- impl CeleryBrokerConnection {
62- pub fn as_celery_database_connection ( & self ) -> & dyn CeleryDatabaseConnection {
67+ impl Deref for CeleryBrokerConnection {
68+ type Target = dyn CeleryDatabaseConnection ;
69+
70+ fn deref ( & self ) -> & Self :: Target {
6371 match self {
6472 Self :: Redis ( r) => r,
6573 Self :: Generic ( g) => g,
0 commit comments