mz_storage_types/connections/
inline.rs1use std::fmt::Debug;
19use std::hash::Hash;
20
21use mz_repr::CatalogItemId;
22use proptest::prelude::Arbitrary;
23use proptest_derive::Arbitrary;
24use serde::{Deserialize, Serialize};
25
26use crate::AlterCompatible;
27
28use super::Connection;
29
30pub trait ConnectionResolver {
35 fn resolve_connection(&self, id: CatalogItemId) -> Connection<InlinedConnection>;
36}
37
38impl<R: ConnectionResolver + ?Sized> ConnectionResolver for &R {
39 fn resolve_connection(&self, id: CatalogItemId) -> Connection<InlinedConnection> {
40 (*self).resolve_connection(id)
41 }
42}
43
44pub trait IntoInlineConnection<T, R: ConnectionResolver + ?Sized> {
52 fn into_inline_connection(self, connection_resolver: R) -> T;
53}
54
55pub trait ConnectionAccess:
58 Arbitrary + Clone + Debug + Eq + PartialEq + Serialize + 'static
59{
60 type Kafka: Arbitrary
61 + Clone
62 + Debug
63 + Eq
64 + PartialEq
65 + Hash
66 + Serialize
67 + for<'a> Deserialize<'a>
68 + AlterCompatible;
69 type Pg: Arbitrary
70 + Clone
71 + Debug
72 + Eq
73 + PartialEq
74 + Hash
75 + Serialize
76 + for<'a> Deserialize<'a>
77 + AlterCompatible;
78 type Aws: Arbitrary
79 + Clone
80 + Debug
81 + Eq
82 + PartialEq
83 + Hash
84 + Serialize
85 + for<'a> Deserialize<'a>
86 + AlterCompatible;
87 type Ssh: Arbitrary
88 + Clone
89 + Debug
90 + Eq
91 + PartialEq
92 + Hash
93 + Serialize
94 + for<'a> Deserialize<'a>
95 + AlterCompatible;
96 type Csr: Arbitrary
97 + Clone
98 + Debug
99 + Eq
100 + PartialEq
101 + Hash
102 + Serialize
103 + for<'a> Deserialize<'a>
104 + AlterCompatible;
105 type MySql: Arbitrary
106 + Clone
107 + Debug
108 + Eq
109 + PartialEq
110 + Hash
111 + Serialize
112 + for<'a> Deserialize<'a>
113 + AlterCompatible;
114 type SqlServer: Arbitrary
115 + Clone
116 + Debug
117 + Eq
118 + PartialEq
119 + Hash
120 + Serialize
121 + for<'a> Deserialize<'a>
122 + AlterCompatible;
123}
124
125#[derive(Arbitrary, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
129pub struct ReferencedConnection;
130
131impl ConnectionAccess for ReferencedConnection {
132 type Kafka = CatalogItemId;
133 type Pg = CatalogItemId;
134 type Aws = CatalogItemId;
135 type Ssh = CatalogItemId;
136 type Csr = CatalogItemId;
137 type MySql = CatalogItemId;
138 type SqlServer = CatalogItemId;
139}
140
141#[derive(Arbitrary, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
143pub struct InlinedConnection;
144
145impl ConnectionAccess for InlinedConnection {
146 type Kafka = super::KafkaConnection;
147 type Pg = super::PostgresConnection;
148 type Aws = super::aws::AwsConnection;
149 type Ssh = super::SshConnection;
150 type Csr = super::CsrConnection;
151 type MySql = super::MySqlConnection;
152 type SqlServer = super::SqlServerConnectionDetails;
153}