pub fn source_persist_desc_from_serialized(
        &self,
        connector: &SourceConnector,
        serialized_details: Option<SerializedSourcePersistDetails>,
    ) -> Result<Option<SourcePersistDesc>, Error> {
        let persister = match self.persister.as_ref() {
            Some(x) => x,
            None => return Ok(None),
        };

        let details = serialized_details.map(|serialized_details| {
            let envelope_desc = match connector {
                SourceConnector::External {
                    envelope: SourceEnvelope::Upsert(_),
                    ..
                } => {
                    assert!(matches!(
                        serialized_details.envelope_details,
                        SerializedEnvelopePersistDetails::Upsert
                    ));
                    EnvelopePersistDesc::Upsert
                }

                SourceConnector::External { envelope, .. } => {
                    return Err(format!("unsupported envelope: {:?}", envelope).into());
                }

                connector => {
                    return Err(format!(
                        "only external sources support persistence, got: {:?}",
                        connector
                    )
                    .into());
                }
            };

            // TODO: We might want to add (or change) a get_description() that allows getting the
            // descriptions for a batch of IDs in one go instead of getting them all separately. It
            // shouldn't be an issue right now, though.
            let primary_stream =
                stream_desc_from_name(serialized_details.primary_stream, persister)?;
            let timestamp_bindings_stream =
                stream_desc_from_name(serialized_details.timestamp_bindings_stream, persister)?;

            Ok(SourcePersistDesc {
                primary_stream,
                timestamp_bindings_stream,
                envelope_desc,
            })
        });

        details.transpose()
    }
// NOTE: This is not a From<SerializedSourcePersistDetails> because we also need access to the
// connector and the persist runtime in future changes.
This is not a From because we also need access to the
connector and the persist runtime in future changes.
This is not a From because we also need access to the connector and the persist runtime in future changes .
pub fn source_persist_desc_from_serialized(
        &self,
        connector: &SourceConnector,
        serialized_details: Option<SerializedSourcePersistDetails>,
    ) -> Result<Option<SourcePersistDesc>, Error> {
        let persister = match self.persister.as_ref() {
            Some(x) => x,
            None => return Ok(None),
        };
        let details = serialized_details.map(|serialized_details| {
            let envelope_desc = match connector {
                SourceConnector::External {
                    envelope: SourceEnvelope::Upsert(_),
                    ..
                } => {
                    assert!(matches!(
                        serialized_details.envelope_details,
                        SerializedEnvelopePersistDetails::Upsert
                    ));
                    EnvelopePersistDesc::Upsert
                }
                SourceConnector::External { envelope, .. } => {
                    return Err(format!("unsupported envelope: {:?}", envelope).into());
                }
                connector => {
                    return Err(format!(
                        "only external sources support persistence, got: {:?}",
                        connector
                    )
                    .into());
                }
            };
            // TODO: We might want to add (or change) a get_description() that allows getting the
            // descriptions for a batch of IDs in one go instead of getting them all separately. It
            // shouldn't be an issue right now, though.
            let primary_stream =
                stream_desc_from_name(serialized_details.primary_stream, persister)?;
            let timestamp_bindings_stream =
                stream_desc_from_name(serialized_details.timestamp_bindings_stream, persister)?;
            Ok(SourcePersistDesc {
                primary_stream,
                timestamp_bindings_stream,
                envelope_desc,
            })
        });
        details.transpose()
    }
pub fn source_persist_desc_from_serialized ( & self , connector : & SourceConnector , serialized_details : Option < SerializedSourcePersistDetails > , ) -> Result < Option < SourcePersistDesc > , Error > { let persister = match self . persister . as_ref ( ) { Some ( x ) => x , None => return Ok ( None ) , } ; let details = serialized_details . map ( | serialized_details | { let envelope_desc = match connector { SourceConnector :: External { envelope : SourceEnvelope :: Upsert ( _ ) , .. } => { assert ! ( matches ( serialized_details envelope_details SerializedEnvelopePersistDetails Upsert ) ) ; EnvelopePersistDesc :: Upsert } SourceConnector :: External { envelope , .. } => { return Err ( format ! ( " " envelope ) . into ( ) ) ; } connector => { return Err ( format ! ( " " connector ) . into ( ) ) ; } } ; // TODO: We might want to add (or change) a get_description() that allows getting the // descriptions for a batch of IDs in one go instead of getting them all separately. It // shouldn't be an issue right now, though. let primary_stream = stream_desc_from_name ( serialized_details . primary_stream , persister ) ? ; let timestamp_bindings_stream = stream_desc_from_name ( serialized_details . timestamp_bindings_stream , persister ) ? ; Ok ( SourcePersistDesc { primary_stream , timestamp_bindings_stream , envelope_desc , } ) } ) ; details . transpose ( ) }
NOTE: This is not a From<SerializedSourcePersistDetails> because we also need access to the
connector and the persist runtime in future changes.
NOTE : This is not a From<SerializedSourcePersistDetails > because we also need access to the connector and the persist runtime in future changes .
&self
connector
&SourceConnector
serialized_details
Option<SerializedSourcePersistDetails>
&self
connector
&SourceConnector
serialized_details
Option<SerializedSourcePersistDetails>