From 6aecad1c9a907c0dc567aef3388bb1857f9ed47d Mon Sep 17 00:00:00 2001 From: Sam Scott Date: Thu, 9 Mar 2017 19:22:01 -0500 Subject: Support serializing sequences. --- src/ser/key.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/ser/key.rs') diff --git a/src/ser/key.rs b/src/ser/key.rs index a84f311..eb7ffae 100644 --- a/src/ser/key.rs +++ b/src/ser/key.rs @@ -1,5 +1,5 @@ use ser::{Error}; -use serde::ser::{SerializeStruct}; +use serde::ser::{SerializeSeq, SerializeStruct}; use ser::part::Sink; use serde::Serialize; use std::borrow::Cow; @@ -42,7 +42,7 @@ impl KeySink } } -impl Sink for KeySink +impl Sink for KeySink where End: for<'key> FnOnce(Key<'key>) -> Result { @@ -93,4 +93,22 @@ where End: for<'key> FnOnce(Key<'key>) -> Result } } +impl SerializeSeq for KeySink +where End: for<'key> FnOnce(Key<'key>) -> Result +{ + type Ok = Ok; + type Error = Error; + + fn serialize_element(&mut self, + _value: &T) + -> Result<(), Error> { + Err(Error::top_level()) + } + + fn end(self) -> Result { + Err(self.unsupported()) + } +} + + -- cgit v1.2.3