(* top-level interface for wire type *)
Definition serialize_top (s : IOStreamWriter.t) : IOStreamWriter.wire :=
IOStreamWriter.wire_wrap s.
Definition deserialize_top {A: Type}
(d : ByteListReader.t A) (w : IOStreamWriter.wire) : option A :=
match ByteListReader.unwrap d (IOStreamWriter.wire_unwrap w) with
| Some (a, []) => Some a
| _ => None
end.

(* Specifications: *)
Lemma serialize_deserialize_top_id' : forall {A} (d : ByteListReader.t A) s v,
ByteListReader.unwrap d (IOStreamWriter.unwrap s) = Some (v, []) ->
deserialize_top d (serialize_top s) = Some v.
Lemma serialize_deserialize_top_invert : forall {A} (d : ByteListReader.t A) s v,
deserialize_top d (serialize_top s) = Some v ->
ByteListReader.unwrap d (IOStreamWriter.unwrap s) = Some (v, []).
Theorem serialize_deserialize_top_id : forall {A : Type} {sA: Serializer A} a,
deserialize_top deserialize (serialize_top (serialize a)) = Some a.
Axiom wire_serialize : IOStreamWriter.wire -> IOStreamWriter.t.
Axiom wire_deserialize : ByteListReader.t IOStreamWriter.wire.
Axiom wire_serialize_deserialize_id :
serialize_deserialize_id_spec wire_serialize wire_deserialize.