From 3362a074c7dddf439ff878cf94d9169ab208eb10 Mon Sep 17 00:00:00 2001 From: Clombrong Date: Thu, 26 Jun 2025 16:59:26 +0200 Subject: refactor(xml): move get and next functions to Xml --- lib/stream.ml | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'lib/stream.ml') diff --git a/lib/stream.ml b/lib/stream.ml index cc15c4b..83587cd 100644 --- a/lib/stream.ml +++ b/lib/stream.ml @@ -1,6 +1,3 @@ -open Lwt.Syntax -open Markup - exception ClosedStream type auth_mechanism = @@ -17,24 +14,6 @@ type stream_features = { unknown_features : Xml.element list; } -(** [next stream] is a promise containing a full stanza of the fragments of - [stream]. *) -let next (stream : (signal, async) stream) : (signal, sync) stream Lwt.t = - let traverse_stanza depth fragment = - let depth = match fragment with - | `Start_element _ -> depth + 1 - | `End_element -> depth - 1 - | _ -> depth - in ([fragment], if depth = 0 then None else Some depth) - in transform traverse_stanza 0 stream |> Markup_lwt.load - -(** [get stream] is a promise containing a single Xml element of [stream]. *) -let get (stream : (signal, async) stream) : Xml.element Lwt.t = - let* signal = next stream - in match Xml.tree signal with - | Some xml -> Lwt.return xml - | None -> Lwt.fail (Xml.InvalidStanza (signal |> write_xml |> to_string)) - (** [parse_features el] is a [stream_features] record with all the features of the [] stanza contained in [el]. *) let parse_features (el : Xml.element) : stream_features = -- cgit v1.2.3