Struct serde::ser::impls::SeqIteratorVisitor [] [src]

pub struct SeqIteratorVisitor<Iter> {
    // some fields omitted
}

A serde::Visitor for sequence iterators.

Examples

use serde::{Serialize, Serializer};
use serde::ser::impls::SeqIteratorVisitor;

struct Seq(Vec<u32>);

impl Serialize for Seq {
    fn serialize<S>(&self, ser: &mut S) -> Result<(), S::Error>
        where S: Serializer,
    {
        ser.visit_seq(SeqIteratorVisitor::new(
            self.0.iter(),
            Some(self.0.len()),
        ))
    }
}

Methods

impl<T, Iter> SeqIteratorVisitor<Iter> where Iter: Iterator<Item=T>

fn new(iter: Iter, len: Option<usize>) -> SeqIteratorVisitor<Iter>

Construct a new SeqIteratorVisitor<Iter>.

Trait Implementations

impl<T, Iter> SeqVisitor for SeqIteratorVisitor<Iter> where T: Serialize, Iter: Iterator<Item=T>

fn visit<S>(&mut self, serializer: &mut S) -> Result<Option<()>, S::Error> where S: Serializer

fn len(&self) -> Option<usize>