Proof using.
intros.
unfold entry_serialize, entry_deserialize.
cheerios_crush.
destruct a;
reflexivity.
Qed.
Instance entry_Serializer : Serializer entry :=
{| serialize := entry_serialize;
deserialize := entry_deserialize;
serialize_deserialize_id := entry_serialize_deserialize_id |}.
Definition msg_serialize (m : msg) : IOStreamWriter.t :=
match m with
| RequestVote t1 n i t2 =>
serialize x00 +$+
serialize t1 +$+
serialize n +$+
serialize i +$+
serialize t2
| RequestVoteReply t b =>
serialize x01 +$+ serialize t +$+ serialize b
| AppendEntries t1 n i1 t2 l2 i2 =>
serialize x02 +$+
serialize t1 +$+
serialize n +$+
serialize i1 +$+
serialize t2 +$+
serialize l2 +$+
serialize i2
| AppendEntriesReply t l b =>
serialize x03 +$+ serialize t +$+ serialize l +$+ serialize b
end.
Definition RequestVote_deserialize : ByteListReader.t msg :=
t1 <- deserialize;;
n <- deserialize;;
i <- deserialize;;
t2 <- deserialize;;
ByteListReader.ret (RequestVote t1 n i t2).
Definition RequestVoteReply_deserialize : ByteListReader.t msg :=
t <- deserialize;;
b <- deserialize;;
ByteListReader.ret (RequestVoteReply t b).
Definition AppendEntries_deserialize : ByteListReader.t msg :=
t1 <- deserialize;;
n <- deserialize;;
i1 <- deserialize;;
t2 <- deserialize;;
l <- deserialize;;
i2 <- deserialize;;
ByteListReader.ret (AppendEntries t1 n i1 t2 l i2).
Definition AppendEntriesReply_deserialize : ByteListReader.t msg :=
t <- deserialize;;
l <- deserialize;;
b <- deserialize;;
ByteListReader.ret (AppendEntriesReply t l b).
Definition msg_deserialize :=
tag <- deserialize;;
match tag with
| x00 => RequestVote_deserialize
| x01 => RequestVoteReply_deserialize
| x02 => AppendEntries_deserialize
| x03 => AppendEntriesReply_deserialize
| _ => ByteListReader.error
end.

(* Specifications: *)
Lemma msg_serialize_deserialize_id :
serialize_deserialize_id_spec msg_serialize msg_deserialize.