mz_compute_types/
sources.rs1use mz_proto::{IntoRustIfSome, ProtoType, RustType, TryFromProtoError};
13use mz_repr::SqlRelationType;
14use mz_storage_types::controller::CollectionMetadata;
15use proptest_derive::Arbitrary;
16use serde::{Deserialize, Serialize};
17
18include!(concat!(env!("OUT_DIR"), "/mz_compute_types.sources.rs"));
19
20#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
26pub struct SourceInstanceDesc<M> {
27 pub arguments: SourceInstanceArguments,
29 pub storage_metadata: M,
31 pub typ: SqlRelationType,
33}
34
35impl RustType<ProtoSourceInstanceDesc> for SourceInstanceDesc<CollectionMetadata> {
36 fn into_proto(&self) -> ProtoSourceInstanceDesc {
37 ProtoSourceInstanceDesc {
38 arguments: Some(self.arguments.into_proto()),
39 storage_metadata: Some(self.storage_metadata.into_proto()),
40 typ: Some(self.typ.into_proto()),
41 }
42 }
43
44 fn from_proto(proto: ProtoSourceInstanceDesc) -> Result<Self, TryFromProtoError> {
45 Ok(SourceInstanceDesc {
46 arguments: proto
47 .arguments
48 .into_rust_if_some("ProtoSourceInstanceDesc::arguments")?,
49 storage_metadata: proto
50 .storage_metadata
51 .into_rust_if_some("ProtoSourceInstanceDesc::storage_metadata")?,
52 typ: proto
53 .typ
54 .into_rust_if_some("ProtoSourceInstanceDesc::typ")?,
55 })
56 }
57}
58
59#[derive(Arbitrary, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
61pub struct SourceInstanceArguments {
62 pub operators: Option<mz_expr::MapFilterProject>,
64}
65
66impl RustType<ProtoSourceInstanceArguments> for SourceInstanceArguments {
67 fn into_proto(&self) -> ProtoSourceInstanceArguments {
68 ProtoSourceInstanceArguments {
69 operators: self.operators.into_proto(),
70 }
71 }
72
73 fn from_proto(proto: ProtoSourceInstanceArguments) -> Result<Self, TryFromProtoError> {
74 Ok(SourceInstanceArguments {
75 operators: proto.operators.into_rust()?,
76 })
77 }
78}