derbyjson 0.0.3

A package to serialize to and deserialize from the DerbyJSON format for roller derby data
/** An object with numeric indices, but acts like an array */
struct IndexedObject<T> {
    inner: Vec<T>,
}

impl Deref<Vec<T>> for IndexedObject<T> {
    fn deref(&self) {

    }

}

impl Serialize for IndexedObject {


}

impl Deserialize for IndexedObject {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
        where D: Deserializer
    {
        deserializer.deserialize_map(IndexedObjectVisitor::new())
        
    
    }
}
// This is an example of a "zero sized type" in Rust. The PhantomData
// keeps the compiler from complaining about unused generic type
// parameters.
struct IndexedObjectVisitor<T> {
    marker: PhantomData<Index<V>>
}

impl<T> MyMapVisitor<T> {
    fn new() -> Self {
        MyMapVisitor {
            marker: PhantomData
        }
    }
}

// This is the trait that Deserializers are going to be driving. There
// is one method for each type of data that our type knows how to
// deserialize from. There are many other methods that are not
// implemented here, for example deserializing from integers or strings.
// By default those methods will return an error, which makes sense
// because we cannot deserialize a MyMap from an integer or string.
impl<T> de::Visitor for MyMapVisitor<T>
    where T: Deserialize,
{
    // The type that our Visitor is going to produce.
    type Value = IndexedObject<T>;

    // Format a message stating what data this Visitor expects to receive.
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("a very special map")
    }

    // Deserialize MyMap from an abstract "map" provided by the
    // Deserializer. The MapVisitor input is a callback provided by
    // the Deserializer to let us see each entry in the map.
    fn visit_map<M>(self, mut visitor: M) -> Result<Self::Value, M::Error>
        where M: de::MapVisitor
    {
        let mut values = MyMap::with_capacity(visitor.size_hint().0);

        // While there are entries remaining in the input, add them
        // into our map.
        while let Some((key, value)) = visitor.visit()? {
            values.insert(key, value);
        }

        Ok(values)
    }

    // As a convenience, provide a way to deserialize MyMap from
    // the abstract "unit" type. This corresponds to `null` in JSON.
    // If your JSON contains `null` for a field that is supposed to
    // be a MyMap, we interpret that as an empty map.
    fn visit_unit<E>(self) -> Result<Self::Value, E>
        where E: de::Error
    {
        Ok(MyMap::new())
    }
}


#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {


    }

}