mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Implement serialization/deserialization for booleans
This commit is contained in:
+8
-2
@@ -288,8 +288,14 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(unabridged, tracing::instrument(level = "trace", skip_all))]
|
#[cfg_attr(unabridged, tracing::instrument(level = "trace", skip_all))]
|
||||||
fn deserialize_bool<V: Visitor<'de>>(self, _visitor: V) -> Result<V::Value> {
|
fn deserialize_bool<V: Visitor<'de>>(self, visitor: V) -> Result<V::Value> {
|
||||||
unhandled!("deserialize bool not implemented")
|
let byte = self
|
||||||
|
.buf
|
||||||
|
.get(self.pos)
|
||||||
|
.ok_or(Self::Error::SerdeDe("bool buffer underflow".into()))?;
|
||||||
|
self.inc_pos(1);
|
||||||
|
|
||||||
|
visitor.visit_bool(*byte != 0x00)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(unabridged, tracing::instrument(level = "trace", skip_all))]
|
#[cfg_attr(unabridged, tracing::instrument(level = "trace", skip_all))]
|
||||||
|
|||||||
+2
-2
@@ -297,8 +297,8 @@ impl<W: Write> ser::Serializer for &mut Serializer<'_, W> {
|
|||||||
|
|
||||||
fn serialize_u8(self, v: u8) -> Result<Self::Ok> { self.write(&[v]) }
|
fn serialize_u8(self, v: u8) -> Result<Self::Ok> { self.write(&[v]) }
|
||||||
|
|
||||||
fn serialize_bool(self, _v: bool) -> Result<Self::Ok> {
|
fn serialize_bool(self, v: bool) -> Result<Self::Ok> {
|
||||||
unhandled!("serialize bool not implemented")
|
if v { self.write(&[0x01]) } else { self.write(&[0x00]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_unit(self) -> Result<Self::Ok> { unhandled!("serialize unit not implemented") }
|
fn serialize_unit(self) -> Result<Self::Ok> { unhandled!("serialize unit not implemented") }
|
||||||
|
|||||||
Reference in New Issue
Block a user