From 77aca3873bf5dda7d5f072acbd210c5c8a77e2bc Mon Sep 17 00:00:00 2001 From: Mark Abspoel Date: Mon, 21 Oct 2024 10:26:32 +0200 Subject: [PATCH] feat: set is_human_readable to false This allows implementations of Serialize to change behavior depending on the encoding method used (e.g. encode as base64 for human readable encodings such as JSON, and encode as binary strings for bencode). --- src/ser.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ser.rs b/src/ser.rs index 5f5d555..c5de147 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -213,6 +213,10 @@ impl<'a> ser::Serializer for &'a mut Serializer { type SerializeStruct = SerializeMap<'a>; type SerializeStructVariant = SerializeMap<'a>; + fn is_human_readable(&self) -> bool { + false + } + fn serialize_bool(self, value: bool) -> Result<()> { self.serialize_i64(i64::from(value)) }