Pure OCaml Yaml 1.2 reader and writer using Bytesrw
at main 3.4 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Loader - converts parser events to YAML data structures *) 7 8(** {1 String-based loading} *) 9 10val value_of_string : 11 ?resolve_aliases:bool -> 12 ?max_nodes:int -> 13 ?max_depth:int -> 14 string -> Value.t 15(** Load single document as Value. 16 17 @param resolve_aliases Whether to resolve aliases (default true) 18 @param max_nodes Maximum nodes during alias expansion (default 10M) 19 @param max_depth Maximum alias nesting depth (default 100) *) 20 21val yaml_of_string : 22 ?resolve_aliases:bool -> 23 ?max_nodes:int -> 24 ?max_depth:int -> 25 string -> Yaml.t 26(** Load single document as Yaml. 27 28 @param resolve_aliases Whether to resolve aliases (default false) 29 @param max_nodes Maximum nodes during alias expansion (default 10M) 30 @param max_depth Maximum alias nesting depth (default 100) *) 31 32val documents_of_string : string -> Document.t list 33(** Load all documents from a string *) 34 35(** {1 Reader-based loading} *) 36 37val value_of_reader : 38 ?resolve_aliases:bool -> 39 ?max_nodes:int -> 40 ?max_depth:int -> 41 Bytesrw.Bytes.Reader.t -> Value.t 42(** Load single document as Value from a Bytes.Reader *) 43 44val yaml_of_reader : 45 ?resolve_aliases:bool -> 46 ?max_nodes:int -> 47 ?max_depth:int -> 48 Bytesrw.Bytes.Reader.t -> Yaml.t 49(** Load single document as Yaml from a Bytes.Reader *) 50 51val documents_of_reader : Bytesrw.Bytes.Reader.t -> Document.t list 52(** Load all documents from a Bytes.Reader *) 53 54(** {1 Parser-based loading} *) 55 56val load_value : 57 ?resolve_aliases:bool -> 58 ?max_nodes:int -> 59 ?max_depth:int -> 60 Parser.t -> Value.t option 61(** Load single Value from parser *) 62 63val load_yaml : Parser.t -> Yaml.t option 64(** Load single Yaml from parser *) 65 66val load_document : Parser.t -> Document.t option 67(** Load single Document from parser *) 68 69val iter_documents : (Document.t -> unit) -> Parser.t -> unit 70(** Iterate over documents from parser *) 71 72val fold_documents : ('a -> Document.t -> 'a) -> 'a -> Parser.t -> 'a 73(** Fold over documents from parser *) 74 75(** {1 Event function-based loading} 76 77 These functions accept a [unit -> Event.spanned option] function 78 instead of a [Parser.t], allowing them to work with any event source. *) 79 80val value_of_parser : 81 ?resolve_aliases:bool -> 82 ?max_nodes:int -> 83 ?max_depth:int -> 84 (unit -> Event.spanned option) -> Value.t 85(** Load single Value from event source function *) 86 87val yaml_of_parser : 88 ?resolve_aliases:bool -> 89 ?max_nodes:int -> 90 ?max_depth:int -> 91 (unit -> Event.spanned option) -> Yaml.t 92(** Load single Yaml from event source function *) 93 94val document_of_parser : (unit -> Event.spanned option) -> Document.t option 95(** Load single Document from event source function *) 96 97val documents_of_parser : (unit -> Event.spanned option) -> Document.t list 98(** Load all documents from event source function *) 99 100val iter_documents_parser : (Document.t -> unit) -> (unit -> Event.spanned option) -> unit 101(** Iterate over documents from event source function *) 102 103val fold_documents_parser : ('a -> Document.t -> 'a) -> 'a -> (unit -> Event.spanned option) -> 'a 104(** Fold over documents from event source function *)