(* 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.

Theorem serialize_deserialize_top_id : forall {A : Type} {sA: Serializer A} a,
deserialize_top deserialize (serialize_top (serialize a)) = Some a.