Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Value is not Decodable after the move to associated types #44

@drbawb

Description

@drbawb

I have a branch that has been tracking rustc-serialize: drbawb/rust-msgpack/feature/rustc-serialize

After the latest changes to the serialize crate (see rust-lang/rust/pull/20514) I have been having lots of issues adopting the current architecture of the library to use associated types.

The biggest hurdle is that the signature of Decodable has changed to the following:

pub trait Decodable {
    fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>;
}

Where D is bound by the trait serialize::Decoder.

This means that inside the decode function we do not have access to the concrete msgpack::Decoder<R> any more.

The previous definition of serialize::Decodable for Value relied on calling the msgpack::Decoder::decode_value() method, which is obviously not accessible through the Decoder trait.

I can't see any way to get access to the concrete decoder.
I even tried std::mem::transmute but because the type parameters for the underlying Reader is also removed from the serialize::Decoder trait: we lack the necessary type information to perform such a cast.


It would appear that the only option left is to re-implement msgpack::Decoder#decode_value() in terms of the generic serialize::Decoder trait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions