Commits

Anonymous committed 7174f92

Checkpoint. Added convenience composers for entity stream reactors.

  • Participants
  • Parent commits 99e20a2

Comments (0)

Files changed (3)

 
 + (unimplemented): Many optional features.
 
-+ (Mime_stream):
-    Provide convenience factories for isimplex, osimplex and duplex reactors
-    that have octet stream plugs on one end and mime stream jacks on the other.
-
 + (Mime_multipart): Need code for parsing and emitting multipart boundaries.
 
 + (Mime_multipart_stream):

File mime/mime_stream.ml

     inherit ['event] emitter ?limits flowTx mimeRx bodyTx
 end
 
-type iplug =
-    (Iom_octet_stream.fragment, Iom_stream.flowcontrol, Iom_stream.failed)
-    Iom_stream.ijack
+type ('i, 'c, 'n) ijack = ('i event, 'c, 'n) Iom_stream.ijack
+    constraint 'i = #Mime_entity.basic_scan_adapter
 
-type oplug =
-    (Iom_octet_stream.fragment, Iom_stream.stop, Iom_stream.flownotify)
-    Iom_stream.ojack
+type ('o, 'c, 'n) ojack = ('o event, 'c, 'n) Iom_stream.ojack
+    constraint 'o = #Mime_entity.basic_emit_adapter
 
-type ioplug =
-    (Iom_octet_stream.fragment, Iom_octet_stream.fragment,
-    Iom_stream.flowcontrol, Iom_stream.flownotify) Iom_stream.iojack
+type ('i, 'o, 'c, 'n) iojack = ('i event, 'o event, 'c, 'n) Iom_stream.iojack
+    constraint 'adapter = #Mime_entity.basic_emit_adapter
 
-type 'i ijack =
-    ('i event, Iom_stream.flowcontrol, Iom_stream.failed)
-    Iom_stream.ijack constraint 'adapter = #Mime_entity.basic_scan_adapter
+type ('c, 'n) entity_scanner_jack =
+    (Mime_entity.basic_scan_adapter, 'c, 'n) ijack
 
-type 'o ojack =
-    ('o event, Iom_stream.stop, Iom_stream.flownotify)
-    Iom_stream.ojack constraint 'adapter = #Mime_entity.basic_emit_adapter
+type ('c, 'n) entity_emitter_jack =
+    (Mime_entity.basic_emit_adapter, 'c, 'n) ojack
 
-type ('i, 'o) iojack =
-    ('i event, 'o event, Iom_stream.flowcontrol, Iom_stream.flownotify)
-    Iom_stream.iojack constraint 'adapter = #Mime_entity.basic_emit_adapter
+type ('c, 'n) entity_io_jack =
+    (Mime_entity.basic_scan_adapter, Mime_entity.basic_emit_adapter, 'c, 'n)
+    iojack
 
-type entity_scanner_jack = Mime_entity.basic_scan_adapter ijack
-type entity_emitter_jack = Mime_entity.basic_emit_adapter ojack
-type entity_iojack =
-    (Mime_entity.basic_scan_adapter, Mime_entity.basic_emit_adapter) iojack
+let scan_entity ~lim ijack =
+    Iom_layer.ingest ijack (new entity_scanner ~lim)
+
+let emit_entity ?limits ojack =
+    Iom_layer.render ojack (new entity_emitter ?limits)
+
+let duplex_entities ~slim ?elim iojack =
+    Iom_layer.duplex iojack
+        (new entity_scanner ~lim:slim) (new entity_emitter ?limits:elim)
 
 (*--- End of File [ mime_stream.ml ] ---*)

File mime/mime_stream.mli

 (*---------------------------------------------------------------------------*
   PLUGS and JACKS
  *---------------------------------------------------------------------------*)
-type iplug =
-    (Iom_octet_stream.fragment, Iom_stream.flowcontrol, Iom_stream.failed)
-    Iom_stream.ijack
+type ('i, 'c, 'n) ijack = ('i event, 'c, 'n) Iom_stream.ijack
+    constraint 'i = #Mime_entity.basic_scan_adapter
 
-type oplug =
-    (Iom_octet_stream.fragment, Iom_stream.stop, Iom_stream.flownotify)
-    Iom_stream.ojack
+type ('o, 'c, 'n) ojack = ('o event, 'c, 'n) Iom_stream.ojack
+    constraint 'o = #Mime_entity.basic_emit_adapter
 
-type ioplug =
-    (Iom_octet_stream.fragment, Iom_octet_stream.fragment,
-    Iom_stream.flowcontrol, Iom_stream.flownotify) Iom_stream.iojack
+type ('i, 'o, 'c, 'n) iojack = ('i event, 'o event, 'c, 'n) Iom_stream.iojack
+    constraint 'adapter = #Mime_entity.basic_emit_adapter
 
-type 'i ijack =
-    ('i event, Iom_stream.flowcontrol, Iom_stream.failed)
-    Iom_stream.ijack constraint 'adapter = #Mime_entity.basic_scan_adapter
+type ('c, 'n) entity_scanner_jack =
+    (Mime_entity.basic_scan_adapter, 'c, 'n) ijack
 
-type 'o ojack =
-    ('o event, Iom_stream.stop, Iom_stream.flownotify)
-    Iom_stream.ojack constraint 'adapter = #Mime_entity.basic_emit_adapter
+type ('c, 'n) entity_emitter_jack =
+    (Mime_entity.basic_emit_adapter, 'c, 'n) ojack
 
-type ('i, 'o) iojack =
-    ('i event, 'o event, Iom_stream.flowcontrol, Iom_stream.flownotify)
-    Iom_stream.iojack constraint 'adapter = #Mime_entity.basic_emit_adapter
+type ('c, 'n) entity_io_jack =
+    (Mime_entity.basic_scan_adapter, Mime_entity.basic_emit_adapter, 'c, 'n)
+    iojack
 
-type entity_scanner_jack = Mime_entity.basic_scan_adapter ijack
-type entity_emitter_jack = Mime_entity.basic_emit_adapter ojack
-type entity_iojack =
-    (Mime_entity.basic_scan_adapter, Mime_entity.basic_emit_adapter) iojack
+val scan_entity:
+    lim:int -> (Iom_octet_stream.fragment, 'c, 'n) Iom_stream.ijack ->
+    ('c, 'n) entity_scanner_jack Iom_gadget.t
+
+val emit_entity :
+    ?limits:Iom_octet_stream.limits ->
+    (Iom_octet_stream.fragment, 'c, 'n) Iom_stream.ojack ->
+    ('c, 'n) entity_emitter_jack Iom_gadget.t
+
+val duplex_entities :
+    slim:int -> ?elim:Iom_octet_stream.limits ->
+    (Iom_octet_stream.fragment, Iom_octet_stream.fragment, 'c, 'n)
+        Iom_stream.iojack ->
+    ('c, 'n) entity_io_jack Iom_gadget.t
 
 (*--- End of File [ mime_stream.mli ] ---*)