diff options
author | Clombrong <cromblong@egregore.fun> | 2025-08-16 00:42:18 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-08-16 00:42:18 +0200 |
commit | ef054dfae34971a28811c5082a4b6041bdfe58dd (patch) | |
tree | c17bb8836b0aa6bc9b3a989510e9b13076acbf9f /lib/xml.ml | |
parent | 96855075812e692cd4ae099f0d27964e306f0f2b (diff) |
feat(xml): make tree function async
Diffstat (limited to 'lib/xml.ml')
-rw-r--r-- | lib/xml.ml | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,4 +1,4 @@ -open Markup +open Lwt.Syntax exception InvalidStanza of string @@ -9,9 +9,9 @@ type element = { children : (element, string) Either.t list; } -(** [tree s] is an [element option] representing the XML element inside of stream [s], - if [s] is a complete element from start to end. *) -let tree s : element option = +(** [tree s] is a promise to an [element option] representing the XML element inside of + stream [s], if [s] is a complete element from start to end. *) +let tree s : element option Lwt.t = let element (namespace, name) attributes children = Either.Left { namespace; @@ -26,7 +26,7 @@ let tree s : element option = children; } and text ss = Either.Right (String.concat "" ss) in - let opt_el = tree ~text ~element s in + let+ opt_el = Markup_lwt.tree ~text ~element s in Option.bind opt_el (Either.fold ~left:Option.some ~right:(fun _ -> None)) (** [element_to_string element] is a string representation of the underlying XML in |