Skip to content
Closed
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
21 changes: 21 additions & 0 deletions serde/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,27 @@ pub trait Serializer: Sized {
len: usize,
) -> Result<Self::SerializeStructVariant, Self::Error>;

/// Serialize a value with a semantic tag for the given format.
///
/// Tagged values are a mechanism supported by some data formats
/// to add additional information to serialized values and to
/// introduce user-defined subtypes.
///
/// The default behavior is to ignore the tag and to serialize
/// just the value.
fn serialize_tagged_value<T: ?Sized, U: ?Sized>(
self,
_format: &'static str,
_tag: &U,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
U: Serialize,
{
value.serialize(self)
}

/// Collect an iterator as a sequence.
///
/// The default implementation serializes each item yielded by the iterator
Expand Down