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

pub struct MapIteratorVisitor<Iter> { /* fields omitted */ }

A serde::Visitor for (key, value) map iterators.

Examples

use std::collections::HashMap;
use serde::{Serialize, Serializer};
use serde::ser::impls::MapIteratorVisitor;

struct Map(HashMap<u32, u32>);

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

Methods

impl<K, V, Iter> MapIteratorVisitor<Iter> where
    Iter: Iterator<Item = (K, V)>, 
[src]

Construct a new MapIteratorVisitor<Iter>.

Trait Implementations

impl<K, V, I> MapVisitor for MapIteratorVisitor<I> where
    K: Serialize,
    V: Serialize,
    I: Iterator<Item = (K, V)>, 
[src]

Serializes a map item in the serializer. Read more

Return the length of the map if known.

Auto Trait Implementations

impl<Iter> Send for MapIteratorVisitor<Iter> where
    Iter: Send

impl<Iter> Sync for MapIteratorVisitor<Iter> where
    Iter: Sync