Add a convenience SomeMsg::parse(bytes) -> Result<SomeMsg, ParseErr>
Rename .deserialize(&mut self) method to .clear_and_parse() (by marking the .deserialized deprecated pointing at the new name, will clean up usages separately) END_PUBLIC Per discussion in the team chat, parse/serialize is the most typical terminology for protobuf impls, we don't have much local reason to diverge. I'm proposing giving the 'better' name to the named ctor since I think that is the one that we expect people to reach for by default; it is generally cleaner than "new then deserialize" pattern since after a parse failure there's not any message still hanging around with implementation-defined contents, along with some other smaller ergonomics benefits. In C++ (when exceptions aren't enabled) all constructors must be infallible, so it can't have it. In Rust there's no language idiom reason why we shouldn't have an associated fn that returns Result<Msg, ParseErr>. PiperOrigin-RevId: 618823998
P
Protobuf Team Bot committed
847d31afb23d2f84cae6ae04876f39dbcf6f6bad
Parent: 0c8f970
Committed by Copybara-Service <copybara-worker@google.com>
on 3/25/2024, 1:43:04 PM