Skip to content

Commit 123d448

Browse files
Derive serde::Serialize for for parse result (#48)
1 parent aee9b4e commit 123d448

File tree

4 files changed

+357
-2
lines changed

4 files changed

+357
-2
lines changed

build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7373
let src_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?).join("src");
7474
env::set_var("OUT_DIR", &src_dir);
7575

76-
prost_build::compile_protos(&[&out_protobuf_path.join("pg_query").with_extension("proto")], &[&out_protobuf_path])?;
76+
let mut prost_build = prost_build::Config::new();
77+
prost_build.type_attribute(".", "#[derive(serde::Serialize)]");
78+
prost_build.compile_protos(&[&out_protobuf_path.join("pg_query").with_extension("proto")], &[&out_protobuf_path])?;
7779

7880
std::fs::rename(src_dir.join("pg_query.rs"), src_dir.join("protobuf.rs"))?;
7981

src/node_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::*;
22

33
pub use protobuf::node::Node as NodeEnum;
44

5-
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
5+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, serde::Serialize)]
66
pub enum Context {
77
None,
88
Select,

0 commit comments

Comments
 (0)