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

Method from_str

src/sql/src/names.rs:948–959  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

946 type Err = PlanError;
947
948 fn from_str(s: &str) -> Result<Self, Self::Err> {
949 let err = || PlanError::Unstructured(format!("couldn't parse SchemaId {}", s));
950 // Validate the (single-byte, ASCII) tag before slicing so that a
951 // multi-byte leading character doesn't slice inside a UTF-8 boundary.
952 let variant = match s.chars().next() {
953 Some('s') => SchemaId::System,
954 Some('u') => SchemaId::User,
955 _ => return Err(err()),
956 };
957 let val: u64 = s[1..].parse().map_err(|_| err())?;
958 Ok(variant(val))
959 }
960}
961
962/// The identifier for a database.

Callers

nothing calls this directly

Calls 3

errFunction · 0.50
nextMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected