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
9 and emitting 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 ->
80 ?max_nodes:int ->
81 ?max_depth:int ->
82 string ->
83 value
84(** Parse a JSON-compatible value from a file. *)
85
86val yaml_of_file :
87 ?resolve_aliases:bool ->
88 ?max_nodes:int ->
89 ?max_depth:int ->
90 string ->
91 yaml
92(** Parse a full YAML value from a file. *)
93
94val documents_of_file : string -> document list
95(** Parse multiple YAML documents from a file. *)
96
97(** {1 File Output} *)
98
99val value_to_file :
100 ?encoding:Yamlrw.Encoding.t ->
101 ?scalar_style:Yamlrw.Scalar_style.t ->
102 ?layout_style:Yamlrw.Layout_style.t ->
103 string ->
104 value ->
105 unit
106(** Write a JSON-compatible value to a file. *)
107
108val yaml_to_file :
109 ?encoding:Yamlrw.Encoding.t ->
110 ?scalar_style:Yamlrw.Scalar_style.t ->
111 ?layout_style:Yamlrw.Layout_style.t ->
112 string ->
113 yaml ->
114 unit
115(** Write a full YAML value to a file. *)
116
117val documents_to_file :
118 ?encoding:Yamlrw.Encoding.t ->
119 ?scalar_style:Yamlrw.Scalar_style.t ->
120 ?layout_style:Yamlrw.Layout_style.t ->
121 ?resolve_aliases:bool ->
122 string ->
123 document list ->
124 unit
125(** Write multiple YAML documents to a file. *)