Merge pull request #1044 from Marwes/human_readable

Serialize to binary if the serde format is not human readable
This commit is contained in:
David Tolnay
2017-10-15 16:39:58 -07:00
committed by GitHub
12 changed files with 605 additions and 110 deletions
+9
View File
@@ -1363,6 +1363,15 @@ pub trait Serializer: Sized {
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: Display;
/// Returns wheter the data format is human readable or not.
///
/// Some formats are not intended to be human readable. For these formats
/// a type being serialized may opt to serialize into a more compact form.
///
/// NOTE: Implementing this method and returning `false` is considered a breaking
/// change as it may alter how any given type tries to serialize itself.
fn is_human_readable(&self) -> bool { true }
}
/// Returned from `Serializer::serialize_seq`.