risingwave_connector_codec/
lib.rs1#![feature(proc_macro_hygiene)]
18#![feature(stmt_expr_attributes)]
19#![feature(error_generic_member_access)]
20#![feature(register_tool)]
21#![register_tool(rw)]
22#![recursion_limit = "256"]
23
24pub mod common;
25pub mod decoder;
28
29pub use apache_avro::schema::Schema as AvroSchema;
30pub use apache_avro::types::{Value as AvroValue, ValueKind as AvroValueKind};
31pub use risingwave_pb::plan_common::ColumnDesc;
32pub struct JsonSchema(pub serde_json::Value);
33impl JsonSchema {
34 pub fn parse_str(schema: &str) -> anyhow::Result<Self> {
35 use anyhow::Context;
36
37 let value = serde_json::from_str(schema).context("failed to parse json schema")?;
38 Ok(Self(value))
39 }
40
41 pub fn parse_bytes(schema: &[u8]) -> anyhow::Result<Self> {
42 use anyhow::Context;
43
44 let value = serde_json::from_slice(schema).context("failed to parse json schema")?;
45 Ok(Self(value))
46 }
47}