diff --git a/protobuf/src/descriptorx.rs b/protobuf-codegen/src/descriptorx.rs similarity index 98% rename from protobuf/src/descriptorx.rs rename to protobuf-codegen/src/descriptorx.rs index 5d8c39196..ad13e17d2 100644 --- a/protobuf/src/descriptorx.rs +++ b/protobuf-codegen/src/descriptorx.rs @@ -1,11 +1,11 @@ //! Utilities to work with descriptor -use descriptor::DescriptorProto; -use descriptor::EnumDescriptorProto; -use descriptor::EnumValueDescriptorProto; -use descriptor::FieldDescriptorProto; -use descriptor::FileDescriptorProto; -use descriptor::OneofDescriptorProto; +use protobuf::descriptor::DescriptorProto; +use protobuf::descriptor::EnumDescriptorProto; +use protobuf::descriptor::EnumValueDescriptorProto; +use protobuf::descriptor::FieldDescriptorProto; +use protobuf::descriptor::FileDescriptorProto; +use protobuf::descriptor::OneofDescriptorProto; use rust; use strx; diff --git a/protobuf-codegen/src/enums.rs b/protobuf-codegen/src/enums.rs index cc3b93ea0..176209c35 100644 --- a/protobuf-codegen/src/enums.rs +++ b/protobuf-codegen/src/enums.rs @@ -1,7 +1,6 @@ use std::collections::HashSet; use protobuf::descriptor::*; -use protobuf::descriptorx::*; use protobuf::prelude::*; @@ -9,6 +8,10 @@ use super::code_writer::*; use super::customize::Customize; use rust_types_values::type_name_to_rust_relative; use serde; +use descriptorx::EnumWithScope; +use descriptorx::EnumValueDescriptorEx; +use descriptorx::RootScope; +use descriptorx::WithScope; #[derive(Clone)] pub struct EnumValueGen { diff --git a/protobuf-codegen/src/extensions.rs b/protobuf-codegen/src/extensions.rs index 77d03a85f..a44cb38d8 100644 --- a/protobuf-codegen/src/extensions.rs +++ b/protobuf-codegen/src/extensions.rs @@ -1,7 +1,9 @@ use super::code_writer::CodeWriter; use super::rust_types_values::*; use protobuf::descriptor::*; -use protobuf::descriptorx::*; +use descriptorx::RootScope; +use descriptorx::FieldDescriptorProtoExt; + struct ExtGen<'a> { file: &'a FileDescriptorProto, diff --git a/protobuf-codegen/src/field.rs b/protobuf-codegen/src/field.rs index 12423f4cc..d2ef21cd4 100644 --- a/protobuf-codegen/src/field.rs +++ b/protobuf-codegen/src/field.rs @@ -1,9 +1,8 @@ use protobuf::prelude::*; use protobuf::descriptor::*; -use protobuf::descriptorx::*; use protobuf::rt; -use protobuf::rust; +use rust; use protobuf::text_format; use protobuf::text_format::lexer::float; use protobuf::wire_format; @@ -19,6 +18,14 @@ use ident::RustIdent; use map::map_entry; use oneof::OneofField; use protobuf::wire_format::WireType; +use descriptorx::MessageOrEnumWithScope; +use descriptorx::FieldDescriptorProtoExt; +use descriptorx::EnumValueDescriptorEx; +use descriptorx::FieldWithContext; +use descriptorx::RootScope; +use descriptorx::WithScope; +use descriptorx::Syntax; + fn type_is_copy(field_type: FieldDescriptorProto_Type) -> bool { match field_type { diff --git a/protobuf-codegen/src/lib.rs b/protobuf-codegen/src/lib.rs index 0e8fb4376..a14ecc04b 100644 --- a/protobuf-codegen/src/lib.rs +++ b/protobuf-codegen/src/lib.rs @@ -8,7 +8,6 @@ use std::io::Write; use std::path::Path; use protobuf::descriptor::*; -use protobuf::descriptorx::*; use protobuf::Message; use protobuf::prelude::*; @@ -28,6 +27,11 @@ mod serde; mod well_known_types; pub mod case_convert; +// used by grpc-rust +pub mod descriptorx; +pub(crate) mod strx; +pub(crate) mod rust; + use customize::customize_from_rustproto_for_file; pub use customize::Customize; @@ -40,6 +44,10 @@ use self::message::*; #[doc(hidden)] pub use amend_io_error_util::amend_io_error; use map::map_entry; +use descriptorx::RootScope; +use descriptorx::FileScope; +use descriptorx::proto_path_to_rust_mod; + fn escape_byte(s: &mut String, b: u8) { if b == b'\n' { diff --git a/protobuf-codegen/src/map.rs b/protobuf-codegen/src/map.rs index b00fddea8..85fa3b201 100644 --- a/protobuf-codegen/src/map.rs +++ b/protobuf-codegen/src/map.rs @@ -1,8 +1,8 @@ use protobuf::prelude::*; use protobuf::descriptor::FieldDescriptorProto_Label; -use protobuf::descriptorx::FieldWithContext; -use protobuf::descriptorx::MessageWithScope; +use descriptorx::FieldWithContext; +use descriptorx::MessageWithScope; /// Pair of (key, value) if this message is map entry pub fn map_entry<'a>( diff --git a/protobuf-codegen/src/message.rs b/protobuf-codegen/src/message.rs index f96c5e47b..e7c688c13 100644 --- a/protobuf-codegen/src/message.rs +++ b/protobuf-codegen/src/message.rs @@ -1,5 +1,4 @@ use protobuf::descriptor::*; -use protobuf::descriptorx::*; use protobuf::prelude::*; @@ -13,6 +12,10 @@ use map::map_entry; use oneof::OneofGen; use oneof::OneofVariantGen; use serde; +use descriptorx::MessageWithScope; +use descriptorx::WithScope; +use descriptorx::RootScope; + /// Message info for codegen pub struct MessageGen<'a> { diff --git a/protobuf-codegen/src/oneof.rs b/protobuf-codegen/src/oneof.rs index 6926ad26c..163bcb742 100644 --- a/protobuf-codegen/src/oneof.rs +++ b/protobuf-codegen/src/oneof.rs @@ -6,9 +6,9 @@ use field::FieldGen; use message::MessageGen; use protobuf::descriptor::FieldDescriptorProto; use protobuf::descriptor::FieldDescriptorProto_Type; -use protobuf::descriptorx::OneofVariantWithContext; -use protobuf::descriptorx::OneofWithContext; -use protobuf::descriptorx::WithScope; +use descriptorx::OneofVariantWithContext; +use descriptorx::OneofWithContext; +use descriptorx::WithScope; use rust_types_values::RustType; use serde; use Customize; diff --git a/protobuf/src/rust.rs b/protobuf-codegen/src/rust.rs similarity index 100% rename from protobuf/src/rust.rs rename to protobuf-codegen/src/rust.rs diff --git a/protobuf-codegen/src/rust_types_values.rs b/protobuf-codegen/src/rust_types_values.rs index 9d70ecaf7..34a23e981 100644 --- a/protobuf-codegen/src/rust_types_values.rs +++ b/protobuf-codegen/src/rust_types_values.rs @@ -4,7 +4,8 @@ use std::fmt; use super::well_known_types::is_well_known_type_full; use ident::RustIdent; use protobuf::descriptor::*; -use protobuf::descriptorx::*; +use descriptorx::RootScope; +use descriptorx::WithScope; // Represent subset of rust types used in generated code #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/protobuf/src/strx.rs b/protobuf-codegen/src/strx.rs similarity index 100% rename from protobuf/src/strx.rs rename to protobuf-codegen/src/strx.rs diff --git a/protobuf/src/lib.rs b/protobuf/src/lib.rs index fee20b279..854481645 100644 --- a/protobuf/src/lib.rs +++ b/protobuf/src/lib.rs @@ -70,15 +70,9 @@ pub mod well_known_types; #[path = "../../protobuf-test-common/src/hex.rs"] mod hex; -// used by rust-grpc -pub mod descriptorx; - mod cached_size; mod chars; mod paginate; -#[doc(hidden)] // used by codegen -pub mod rust; -mod strx; mod unknown; mod varint; mod zigzag; @@ -93,7 +87,6 @@ mod protobuf { pub use clear::Clear; pub use core::*; pub use descriptor; - pub use descriptorx; pub use enums::ProtobufEnum; pub use error::*; pub use ext;