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

Method try_from_value

src/sql/src/kafka_util.rs:70–84  ·  view source on GitHub ↗
(v: Value)

Source from the content-addressed store, hash-verified

68
69impl TryFromValue<Value> for KafkaSinkCompressionType {
70 fn try_from_value(v: Value) -> Result<Self, PlanError> {
71 match v {
72 Value::String(v) => match v.to_lowercase().as_str() {
73 "none" => Ok(KafkaSinkCompressionType::None),
74 "gzip" => Ok(KafkaSinkCompressionType::Gzip),
75 "snappy" => Ok(KafkaSinkCompressionType::Snappy),
76 "lz4" => Ok(KafkaSinkCompressionType::Lz4),
77 "zstd" => Ok(KafkaSinkCompressionType::Zstd),
78 // The caller will add context, resulting in an error like
79 // "invalid COMPRESSION TYPE: <bad-compression-type>".
80 _ => sql_bail!("{}", v),
81 },
82 _ => sql_bail!("compression type must be a string"),
83 }
84 }
85
86 fn try_into_value(self, _catalog: &dyn SessionCatalog) -> Option<Value> {
87 Some(Value::String(match self {

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected