Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(prost-types): Add description of using Any #1141

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions prost-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@
//!
//! See the [Protobuf reference][1] for more information about well-known types.
//!
//! ## Any
//!
//! The well-known [`Any`] type contains an arbitrary serialized message along with a URL that
//! describes the type of the serialized message. Every message that also implements [`Name`]
//! can be serialized to and deserialized from [`Any`].
//!
//! ### Serialization
//!
//! A message can be serialized using [`Any::from_msg`].
//!
//! ```rust
//! let message = Timestamp::date(2000, 1, 1).unwrap();
//! let any = Any::from_msg(&message).unwrap();
//! ```
//!
//! ### Deserialization
//!
//! A message can be deserialized using [`Any::to_msg`].
//!
//! ```rust
//! # let message = Timestamp::date(2000, 1, 1).unwrap();
//! # let any = Any::from_msg(&message).unwrap();
//! #
//! let message = any.to_msg::<Timestamp>().unwrap();
//! ```
//!
//! ## Feature Flags
//! - `std`: Enable integration with standard library. Disable this feature for `no_std` support. This feature is enabled by default.
//!
Expand Down