MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_connection_rule_pattern

Method parse_connection_rule_pattern

src/sql-parser/src/parser.rs:2720–2749  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

2718 }
2719
2720 fn parse_connection_rule_pattern(&mut self) -> Result<ConnectionRulePattern, ParserError> {
2721 let s = self.parse_literal_string()?;
2722 let pos = self.peek_prev_pos();
2723 let mut prefix_wildcard = false;
2724 let mut suffix_wildcard = false;
2725 let mut remainder = &s[..];
2726
2727 if let Some(stripped) = remainder.strip_prefix('*') {
2728 prefix_wildcard = true;
2729 remainder = stripped;
2730 }
2731 if let Some(stripped) = remainder.strip_suffix('*') {
2732 suffix_wildcard = true;
2733 remainder = stripped;
2734 }
2735
2736 if remainder.contains('*') {
2737 return parser_err!(
2738 self,
2739 pos,
2740 "pattern may only contain `*` as a leading and/or trailing wildcard"
2741 );
2742 }
2743
2744 Ok(ConnectionRulePattern {
2745 prefix_wildcard,
2746 literal_match: remainder.to_owned(),
2747 suffix_wildcard,
2748 })
2749 }
2750
2751 fn parse_kafka_broker_or_matching_rule(&mut self) -> Result<WithOptionValue<Raw>, ParserError> {
2752 if self.parse_keyword(MATCHING) {

Calls 4

parse_literal_stringMethod · 0.80
peek_prev_posMethod · 0.80
containsMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected