Skip to content

Commit 23ef525

Browse files
committed
doc: buffered writer is preffered
1 parent 954f758 commit 23ef525

File tree

1 file changed

+12
-0
lines changed
  • datadog-profiling-protobuf/src

1 file changed

+12
-0
lines changed

datadog-profiling-protobuf/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
//! # Ok(()) }
3434
//! ```
3535
//!
36+
//! Serialization often happens one byte at a time, so a buffered writer
37+
//! should probably be used.
38+
//!
3639
//! There is no serializer for Profile. It would require borrowing a lot of
3740
//! data, which becomes unwieldy. It also isn't very compatible with writing
3841
//! a streaming serializer to lower peak memory usage.
@@ -85,6 +88,9 @@ pub trait Value {
8588
fn proto_len(&self) -> u64;
8689

8790
/// Encode the value to the in-wire protobuf format.
91+
///
92+
/// Serialization often happens one byte at a time, so a buffered writer
93+
/// should probably be used.
8894
fn encode<W: Write>(&self, writer: &mut W) -> io::Result<()>;
8995

9096
/// Create a Pair with the given field. The wire type will be added
@@ -124,6 +130,9 @@ impl<V: Value> Pair<V> {
124130

125131
/// Encodes the pair into protobuf, without the zero-size optimization.
126132
///
133+
/// Serialization often happens one byte at a time, so a buffered writer
134+
/// should probably be used.
135+
///
127136
/// # Examples
128137
///
129138
/// Given a message like:
@@ -186,6 +195,9 @@ impl<V: Value> WithZeroOptimization<V> {
186195
/// doesn't require fields with values of zero to be present, so to save
187196
/// space, they can be omitted them altogether.
188197
///
198+
/// Serialization often happens one byte at a time, so a buffered writer
199+
/// should probably be used.
200+
///
189201
/// # Examples
190202
///
191203
/// Label is a great message to demonstrate how the optimization is useful

0 commit comments

Comments
 (0)