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

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.