You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did #878 and we discussed it on Discord, where @LucioFranco said they don't have the time to maintain and review bigger features PRs like this one.
In the spirit of removing maintenance burden from prost maintainers, I want to improve the experience of implementing prost::Message for one's own type, in downstream crates. This issue is listing the problems and blockers I find, and, if any, the solutions I'm proposing
This causes a few issues: Rust Analyzer "Implement Missing Members" assist doesn't pick them up, which causes surprising behaviour when just using todo!() to implement missing methods to start trying things out. (This is a bug in rust-analyzer, but still, it means the experience is not as nice)
It also mean the docs don't help at all when looking at the docs for the error source.
Possible solutions
Don't hide the methods: it was done for a reason, so probably a no ? It would at least not be a breaking change. We could document the methods as "not for regular use"
Use a RawMessage trait and make the definition of Message depend on it: Message: RawMessage + Debug + .... breaking change
Implementing prost::Message for new types can be impossible to do efficiently
Using this:
use prost::bytes::{Buf,BufMut};use prost::encoding::{DecodeContext,WireType};use prost::DecodeError;#[derive(Debug)]pubstructBoxStr(Box<str>);impl prost::MessageforBoxStr{fnencoded_len(&self) -> usize{todo!()}fnclear(&mutself){todo!()}fnencode_raw<B>(&self,buf:&mutB)whereB:BufMut,Self:Sized,{todo!()}fnmerge_field<B>(&mutself,tag:u32,wire_type:WireType,buf:&mutB,ctx:DecodeContext,) -> Result<(),DecodeError>whereB:Buf,Self:Sized,{todo!()}}
Implementing Message here is impossible to do efficiently:
All methods except clear need a conversion to String to use its Message impl
prost doesn't expose any utilities to work on &str for non-mutating methods
WireType and DecodeContext are doc(hidden) so finding documentation on how to use them is harder than necessary. WireType is fully undocumented too, adding to the task.
The text was updated successfully, but these errors were encountered:
I did #878 and we discussed it on Discord, where @LucioFranco said they don't have the time to maintain and review bigger features PRs like this one.
In the spirit of removing maintenance burden from
prost
maintainers, I want to improve the experience of implementingprost::Message
for one's own type, in downstream crates. This issue is listing the problems and blockers I find, and, if any, the solutions I'm proposingRequired
doc(hidden)
methods in the traitTwo required methods are
doc(hidden)
: look at the compiled docs and the source for the trait:encode_raw
andmerge_field
are hidden.This causes a few issues: Rust Analyzer "Implement Missing Members" assist doesn't pick them up, which causes surprising behaviour when just using
todo!()
to implement missing methods to start trying things out. (This is a bug in rust-analyzer, but still, it means the experience is not as nice)It also mean the docs don't help at all when looking at the docs for the error source.
Possible solutions
RawMessage
trait and make the definition ofMessage
depend on it:Message: RawMessage + Debug + ...
. breaking changeImplementing
prost::Message
for new types can be impossible to do efficientlyUsing this:
Implementing
Message
here is impossible to do efficiently:clear
need a conversion toString
to use itsMessage
implprost
doesn't expose any utilities to work on&str
for non-mutating methodsWireType
andDecodeContext
aredoc(hidden)
so finding documentation on how to use them is harder than necessary.WireType
is fully undocumented too, adding to the task.The text was updated successfully, but these errors were encountered: