Skip to content

Commit

Permalink
cherry-pick "support faststr for protobuf" (#162)
Browse files Browse the repository at this point in the history
* support faststr for protobuf

* absolute path for `try_from`
  • Loading branch information
LYF1999 authored May 22, 2023
1 parent fad23f5 commit 814cf9d
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 86 deletions.
122 changes: 61 additions & 61 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pilota-build/src/codegen/protobuf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ impl ProtobufBackend {
.and_then(|tags| tags.get::<ProstType>().copied());
Ident::new(
match ty.kind {
ty::TyKind::String | ty::TyKind::FastStr => "string",
ty::TyKind::String => "string",
ty::TyKind::FastStr => "faststr",
ty::TyKind::Bool => "bool",
ty::TyKind::BytesVec | ty::TyKind::Bytes => "bytes",
ty::TyKind::I32 if prost_type == Some(ProstType::SFixed32) => "sfixed32",
Expand Down
2 changes: 1 addition & 1 deletion pilota-build/src/codegen/thrift/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl CodegenBackend for ThriftBackend {
let err_msg_tmpl = format!("invalid enum value for {}, value: {{}}", name);
format! {
r#"let value = {read_i32};
Ok(Self::try_from(value).map_err(|_|
Ok(::std::convert::TryFrom::try_from(value).map_err(|err|
::pilota::thrift::DecodeError::new(
::pilota::thrift::DecodeErrorKind::InvalidData,
format!("{err_msg_tmpl}", value)
Expand Down
Loading

0 comments on commit 814cf9d

Please sign in to comment.