Pure OCaml Yaml 1.2 reader and writer using Bytesrw
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Yamlrw Unix - Channel and file I/O for YAML
7
8 This module provides channel and file operations for parsing and emitting
9 YAML using bytesrw for efficient streaming I/O. *)
10
11(** {1 Types} *)
12
13type value = Yamlrw.Value.t
14type yaml = Yamlrw.Yaml.t
15type document = Yamlrw.Document.t
16
17(** {1 Channel Input} *)
18
19val value_of_channel :
20 ?resolve_aliases:bool ->
21 ?max_nodes:int ->
22 ?max_depth:int ->
23 in_channel ->
24 value
25(** Parse a JSON-compatible value from an input channel.
26
27 @param resolve_aliases Whether to expand aliases (default: true)
28 @param max_nodes Maximum nodes during alias expansion (default: 10M)
29 @param max_depth Maximum alias nesting depth (default: 100) *)
30
31val yaml_of_channel :
32 ?resolve_aliases:bool ->
33 ?max_nodes:int ->
34 ?max_depth:int ->
35 in_channel ->
36 yaml
37(** Parse a full YAML value from an input channel.
38
39 @param resolve_aliases Whether to expand aliases (default: false)
40 @param max_nodes Maximum nodes during alias expansion (default: 10M)
41 @param max_depth Maximum alias nesting depth (default: 100) *)
42
43val documents_of_channel : in_channel -> document list
44(** Parse multiple YAML documents from an input channel. *)
45
46(** {1 Channel Output} *)
47
48val value_to_channel :
49 ?encoding:Yamlrw.Encoding.t ->
50 ?scalar_style:Yamlrw.Scalar_style.t ->
51 ?layout_style:Yamlrw.Layout_style.t ->
52 out_channel ->
53 value ->
54 unit
55(** Write a JSON-compatible value to an output channel. *)
56
57val yaml_to_channel :
58 ?encoding:Yamlrw.Encoding.t ->
59 ?scalar_style:Yamlrw.Scalar_style.t ->
60 ?layout_style:Yamlrw.Layout_style.t ->
61 out_channel ->
62 yaml ->
63 unit
64(** Write a full YAML value to an output channel. *)
65
66val documents_to_channel :
67 ?encoding:Yamlrw.Encoding.t ->
68 ?scalar_style:Yamlrw.Scalar_style.t ->
69 ?layout_style:Yamlrw.Layout_style.t ->
70 ?resolve_aliases:bool ->
71 out_channel ->
72 document list ->
73 unit
74(** Write multiple YAML documents to an output channel. *)
75
76(** {1 File Input} *)
77
78val value_of_file :
79 ?resolve_aliases:bool -> ?max_nodes:int -> ?max_depth:int -> string -> value
80(** Parse a JSON-compatible value from a file. *)
81
82val yaml_of_file :
83 ?resolve_aliases:bool -> ?max_nodes:int -> ?max_depth:int -> string -> yaml
84(** Parse a full YAML value from a file. *)
85
86val documents_of_file : string -> document list
87(** Parse multiple YAML documents from a file. *)
88
89(** {1 File Output} *)
90
91val value_to_file :
92 ?encoding:Yamlrw.Encoding.t ->
93 ?scalar_style:Yamlrw.Scalar_style.t ->
94 ?layout_style:Yamlrw.Layout_style.t ->
95 string ->
96 value ->
97 unit
98(** Write a JSON-compatible value to a file. *)
99
100val yaml_to_file :
101 ?encoding:Yamlrw.Encoding.t ->
102 ?scalar_style:Yamlrw.Scalar_style.t ->
103 ?layout_style:Yamlrw.Layout_style.t ->
104 string ->
105 yaml ->
106 unit
107(** Write a full YAML value to a file. *)
108
109val documents_to_file :
110 ?encoding:Yamlrw.Encoding.t ->
111 ?scalar_style:Yamlrw.Scalar_style.t ->
112 ?layout_style:Yamlrw.Layout_style.t ->
113 ?resolve_aliases:bool ->
114 string ->
115 document list ->
116 unit
117(** Write multiple YAML documents to a file. *)