Adjust the protobuf prelude.

Export the traits with a `Proto` prefix on them to minimize collisions (especially the high risk of confusing collision with the std prelude's AsMut).

Remove Message, MessageMut and MessageView from the prelude.

PiperOrigin-RevId: 691388401
pull/19010/head
Protobuf Team Bot 4 weeks ago committed by Copybara-Service
parent afb20af442
commit 5fe1196572
  1. 2
      conformance/conformance_rust.rs
  2. 17
      rust/prelude.rs

@ -8,7 +8,7 @@ use conformance_rust_proto::{ConformanceRequest, ConformanceResponse, WireFormat
use protobuf::prelude::*; use protobuf::prelude::*;
use protobuf::Optional::{Set, Unset}; use protobuf::Optional::{Set, Unset};
use protobuf::ParseError; use protobuf::{Message, ParseError};
use std::io::{self, ErrorKind, Read, Write}; use std::io::{self, ErrorKind, Read, Write};
use test_messages_edition2023_rust_proto::TestAllTypesEdition2023; use test_messages_edition2023_rust_proto::TestAllTypesEdition2023;

@ -6,11 +6,18 @@
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
//! Prelude for the Protobuf Rust API. //! Prelude for the Protobuf Rust API.
//! This module contains only non-struct items that are needed for extremely //!
//! common usages of the generated types from application code. Any struct //! This module contains only the proto! macro and traits which define very
//! or less common items should be imported normally. //! common fns that on messages (fns that would be methods on a base class in
//! other languages).
//!
//! All traits here have `Proto` prefixed on them, as the intent of this prelude
//! is to make the methods callable on message instances: if the traits are
//! named for generic reasons, they should be explicitly imported from the
//! `protobuf::` crate instead.
pub use crate::{ pub use crate::{
proto, AsMut, AsView, Clear, ClearAndParse, IntoMut, IntoView, MergeFrom, Message, MessageMut, proto, AsMut as ProtoAsMut, AsView as ProtoAsView, Clear as ProtoClear,
MessageView, Parse, Serialize, ClearAndParse as ProtoClearAndParse, IntoMut as ProtoIntoMut, IntoView as ProtoIntoView,
MergeFrom as ProtoMergeFrom, Parse as ProtoParse, Serialize as ProtoSerialize,
}; };

Loading…
Cancel
Save