fn try_from(params: DataSourceParams) -> Result<Self, Self::Error> {
        match params.uri {
            None => Ok(Box::new(StdoutExportStrategy)),
            Some(uri) => {
                let export_strategy: Box<dyn ExportStrategy> = if uri.starts_with("postgres://")
                    || uri.starts_with("postgresql://")
                {
                    Box::new(PostgresExportStrategy {
                        uri,
                        schema: params.schema,
                    })
                } else if uri.starts_with("mongodb://") {
                    Box::new(MongoExportStrategy { uri })
                } else if uri.starts_with("mysql://") || uri.starts_with("mariadb://") {
                    Box::new(MySqlExportStrategy { uri })
                } else {
                    return Err(anyhow!(
                            "Data sink not recognized. Was expecting one of 'mongodb' or 'postgres' or 'mysql' or 'mariadb'"
                    ));
                };
                Ok(export_strategy)
            }
        }
    }
/// Here we exhaustively try to pattern match strings until we get something
/// that successfully parses. Starting from a file, could be a url to a database etc.
/// We assume that these can be unambiguously identified for now.
/// For example, `postgres://...` is not going to be a file on the FS
Here we exhaustively try to pattern match strings until we get something
that successfully parses. Starting from a file, could be a url to a database etc.
We assume that these can be unambiguously identified for now.
For example, `postgres://...` is not going to be a file on the FS
Here we exhaustively try to pattern match strings until we get something that successfully parses . Starting from a file could be a url to a database etc . We assume that these can be unambiguously identified for now . For example ` postgres : // ... ` is not going to be a file on the FS
fn try_from(params: DataSourceParams) -> Result<Self, Self::Error> {
        match params.uri {
            None => Ok(Box::new(StdoutExportStrategy)),
            Some(uri) => {
                let export_strategy: Box<dyn ExportStrategy> = if uri.starts_with("postgres://")
                    || uri.starts_with("postgresql://")
                {
                    Box::new(PostgresExportStrategy {
                        uri,
                        schema: params.schema,
                    })
                } else if uri.starts_with("mongodb://") {
                    Box::new(MongoExportStrategy { uri })
                } else if uri.starts_with("mysql://") || uri.starts_with("mariadb://") {
                    Box::new(MySqlExportStrategy { uri })
                } else {
                    return Err(anyhow!(
                            "Data sink not recognized. Was expecting one of 'mongodb' or 'postgres' or 'mysql' or 'mariadb'"
                    ));
                };
                Ok(export_strategy)
            }
        }
    }
fn try_from ( params : DataSourceParams ) -> Result < Self , Self :: Error > { match params . uri { None => Ok ( Box :: new ( StdoutExportStrategy ) ) , Some ( uri ) => { let export_strategy : Box < dyn ExportStrategy > = if uri . starts_with ( " " ) || uri . starts_with ( " " ) { Box :: new ( PostgresExportStrategy { uri , schema : params . schema , } ) } else if uri . starts_with ( " " ) { Box :: new ( MongoExportStrategy { uri } ) } else if uri . starts_with ( " " ) || uri . starts_with ( " " ) { Box :: new ( MySqlExportStrategy { uri } ) } else { return Err ( anyhow ! ( " " ) ) ; } ; Ok ( export_strategy ) } } }
Here we exhaustively try to pattern match strings until we get something
that successfully parses.
Here we exhaustively try to pattern match strings until we get something that successfully parses .
params
DataSourceParams
params
DataSourceParams