Skip to main content

libyml/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! # ⚠️ `libyml` is deprecated — migrate to a maintained alternative
4//!
5//! This crate is **unmaintained**. The `0.0.6` release is a thin
6//! compatibility shim so existing call sites keep working while you
7//! plan a migration. See [`MIGRATION.md`](https://github.com/sebastienrousseau/libyml/blob/master/MIGRATION.md)
8//! for the full guide.
9//!
10//! ## Maintained alternatives
11//!
12//! - **[`unsafe-libyaml`](https://crates.io/crates/unsafe-libyaml)**
13//!   — the upstream Rust translation of C `libyaml` that `libyml`
14//!   was originally forked from. Same `yaml_*` function surface,
15//!   actively maintained. **Drop-in replacement** for users on the
16//!   raw FFI-shaped API.
17//! - **[`yaml-rust2`](https://crates.io/crates/yaml-rust2)** —
18//!   pure-Rust low-level parser, no FFI. Returns a `Yaml` enum AST
19//!   instead of the event-stream model. Fits users who want to move
20//!   off the C-libyaml shape entirely while keeping a low-level
21//!   parser primitive.
22//! - **[`noyalib`](https://crates.io/crates/noyalib)** — modern,
23//!   pure-Rust, `#![forbid(unsafe_code)]` YAML library with a
24//!   high-level typed API (`from_str::<T>` / `Value`). Fits users
25//!   who can move from event-stream parsing to typed deserialisation.
26//!
27//! `MIGRATION.md` carries the per-crate mapping tables.
28//!
29//! ## Why the shim is backed by `unsafe-libyaml`
30//!
31//! `libyml` was originally a fork of `unsafe-libyaml` with cosmetic
32//! renames (snake_case → PascalCase for type names). The 0.0.6 shim
33//! reverts those renames internally and re-exports the upstream's
34//! functions and types, restoring the historical PascalCase aliases
35//! so existing call sites compile unchanged.
36//!
37//! This is an implementation detail, not a recommendation that you
38//! must use `unsafe-libyaml`. Two things follow:
39//!
40//! - **No duplicated `unsafe` translation in the dependency graph.**
41//!   Downstream users link the upstream's audited copy of the
42//!   C-libyaml translation rather than this fork's stale copy.
43//! - **Bug fixes flow through.** Anything fixed in
44//!   `unsafe-libyaml` lands in users of this shim on a plain
45//!   `cargo update`, without a new `libyml` release.
46//!
47//! If you want to evaluate `yaml-rust2` or `noyalib` directly,
48//! `MIGRATION.md` covers both.
49//!
50//! ## Stop-gap: keep using `libyml = "0.0.6"`
51//!
52//! Existing call sites compile unchanged against this shim. Every
53//! item below is marked `#[deprecated]`, so the compiler will point
54//! at the spots that need updating during your migration.
55//!
56//! ## What still resolves under `libyml::*` (0.0.6)
57//!
58//! Most of the previous public surface is **retained** via thin
59//! re-export modules pointing at `unsafe-libyaml`:
60//!
61//! - [`libyml::api`](crate::api) — parser/emitter init + event
62//!   initialisers.
63//! - [`libyml::decode`](crate::decode) — `yaml_parser_initialize`
64//!   / `_delete`.
65//! - [`libyml::document`](crate::document) — `yaml_document_*`
66//!   helpers.
67//! - [`libyml::dumper`](crate::dumper) — `yaml_emitter_open`
68//!   / `_close` / `_dump`.
69//! - [`libyml::loader`](crate::loader) — `yaml_parser_load`.
70//! - [`libyml::yaml`](crate::yaml) — every PascalCase type alias
71//!   and PascalCase enum-variant constant.
72//! - [`libyml::success`](crate::success) — `is_success(bool)` /
73//!   `is_failure(bool)` helpers (the `Success` struct itself is
74//!   no longer nameable — read `.ok` instead).
75//!
76//! The historical [`libyml::memory`](crate::memory) and
77//! [`libyml::string`](crate::string) paths still resolve, but as
78//! **empty stub modules** — every former item under them is gone
79//! because they belonged to the hand-translated C copy this shim
80//! deletes (`libyml::string::yaml_string_extend` is the unsound
81//! helper RUSTSEC-2025-0067 flags).
82//!
83//! ## Removed in 0.0.6 (vs. 0.0.5)
84//!
85//! The implementation-detail modules — `libyml::internal`,
86//! `libyml::macros`, `libyml::externs`, `libyml::utils`,
87//! `libyml::libc`, the contents of `libyml::memory` and
88//! `libyml::string`, and the `yaml-test-suite` runner binaries
89//! under `src/bin/` — are **gone** in this release. See
90//! `MIGRATION.md` for the equivalence table per alternative.
91
92#![deprecated(
93    since = "0.0.6",
94    note = "libyml is unmaintained. Migrate to a maintained alternative (unsafe-libyaml, yaml-rust2, or noyalib). See MIGRATION.md."
95)]
96#![doc(html_root_url = "https://docs.rs/libyml/0.0.6")]
97#![no_std]
98// The PascalCase `pub const Yaml*` aliases below intentionally
99// shadow the upstream's SCREAMING_SNAKE_CASE variants so existing
100// `libyml`-flavoured call sites compile unchanged. The
101// `non_upper_case_globals` lint flags this naming convention as
102// non-idiomatic; the alias is the entire point.
103#![allow(non_upper_case_globals)]
104
105// ── Top-level function re-exports — name-for-name with libyml 0.0.5 ────
106
107#[doc(inline)]
108pub use unsafe_libyaml::{
109    yaml_alias_event_initialize, yaml_document_delete,
110    yaml_document_end_event_initialize, yaml_document_get_node,
111    yaml_document_get_root_node, yaml_document_initialize,
112    yaml_document_start_event_initialize, yaml_emitter_close,
113    yaml_emitter_delete, yaml_emitter_dump, yaml_emitter_emit,
114    yaml_emitter_flush, yaml_emitter_initialize, yaml_emitter_open,
115    yaml_emitter_set_break, yaml_emitter_set_canonical,
116    yaml_emitter_set_encoding, yaml_emitter_set_indent,
117    yaml_emitter_set_output, yaml_emitter_set_output_string,
118    yaml_emitter_set_unicode, yaml_emitter_set_width,
119    yaml_event_delete, yaml_mapping_end_event_initialize,
120    yaml_mapping_start_event_initialize, yaml_parser_delete,
121    yaml_parser_initialize, yaml_parser_load, yaml_parser_parse,
122    yaml_parser_scan, yaml_parser_set_encoding, yaml_parser_set_input,
123    yaml_parser_set_input_string, yaml_scalar_event_initialize,
124    yaml_sequence_end_event_initialize,
125    yaml_sequence_start_event_initialize,
126    yaml_stream_end_event_initialize,
127    yaml_stream_start_event_initialize, yaml_token_delete,
128};
129
130// ── Type aliases — restore the PascalCase names libyml ≤ 0.0.5 used ────
131//
132// `unsafe-libyaml` uses C-style snake_case (`yaml_event_t`,
133// `yaml_parser_t`, …); `libyml` historically renamed those to
134// PascalCase (`YamlEventT`, `YamlParserT`, …). The aliases below
135// preserve the historical name surface so `use libyml::YamlParserT`
136// keeps resolving.
137
138/// Alias for [`unsafe_libyaml::yaml_alias_data_t`].
139pub type YamlAliasDataT = unsafe_libyaml::yaml_alias_data_t;
140/// Alias for [`unsafe_libyaml::yaml_break_t`].
141pub type YamlBreakT = unsafe_libyaml::yaml_break_t;
142/// Alias for [`unsafe_libyaml::yaml_document_t`].
143pub type YamlDocumentT = unsafe_libyaml::yaml_document_t;
144/// Alias for [`unsafe_libyaml::yaml_emitter_state_t`].
145pub type YamlEmitterStateT = unsafe_libyaml::yaml_emitter_state_t;
146/// Alias for [`unsafe_libyaml::yaml_emitter_t`].
147pub type YamlEmitterT = unsafe_libyaml::yaml_emitter_t;
148/// Alias for [`unsafe_libyaml::yaml_encoding_t`].
149pub type YamlEncodingT = unsafe_libyaml::yaml_encoding_t;
150/// Alias for [`unsafe_libyaml::yaml_error_type_t`].
151pub type YamlErrorTypeT = unsafe_libyaml::yaml_error_type_t;
152/// Alias for [`unsafe_libyaml::yaml_event_t`].
153pub type YamlEventT = unsafe_libyaml::yaml_event_t;
154/// Alias for [`unsafe_libyaml::yaml_event_type_t`].
155pub type YamlEventTypeT = unsafe_libyaml::yaml_event_type_t;
156/// Alias for [`unsafe_libyaml::yaml_mapping_style_t`].
157pub type YamlMappingStyleT = unsafe_libyaml::yaml_mapping_style_t;
158/// Alias for [`unsafe_libyaml::yaml_mark_t`].
159pub type YamlMarkT = unsafe_libyaml::yaml_mark_t;
160/// Alias for [`unsafe_libyaml::yaml_node_item_t`].
161pub type YamlNodeItemT = unsafe_libyaml::yaml_node_item_t;
162/// Alias for [`unsafe_libyaml::yaml_node_pair_t`].
163pub type YamlNodePairT = unsafe_libyaml::yaml_node_pair_t;
164/// Alias for [`unsafe_libyaml::yaml_node_t`].
165pub type YamlNodeT = unsafe_libyaml::yaml_node_t;
166/// Alias for [`unsafe_libyaml::yaml_node_type_t`].
167pub type YamlNodeTypeT = unsafe_libyaml::yaml_node_type_t;
168/// Alias for [`unsafe_libyaml::yaml_parser_state_t`].
169pub type YamlParserStateT = unsafe_libyaml::yaml_parser_state_t;
170/// Alias for [`unsafe_libyaml::yaml_parser_t`].
171pub type YamlParserT = unsafe_libyaml::yaml_parser_t;
172/// Alias for [`unsafe_libyaml::yaml_read_handler_t`].
173pub type YamlReadHandlerT = unsafe_libyaml::yaml_read_handler_t;
174/// Alias for [`unsafe_libyaml::yaml_scalar_style_t`].
175pub type YamlScalarStyleT = unsafe_libyaml::yaml_scalar_style_t;
176/// Alias for [`unsafe_libyaml::yaml_sequence_style_t`].
177pub type YamlSequenceStyleT = unsafe_libyaml::yaml_sequence_style_t;
178/// Alias for [`unsafe_libyaml::yaml_simple_key_t`].
179pub type YamlSimpleKeyT = unsafe_libyaml::yaml_simple_key_t;
180/// Alias for [`unsafe_libyaml::yaml_stack_t`].
181pub type YamlStackT<T> = unsafe_libyaml::yaml_stack_t<T>;
182/// Alias for [`unsafe_libyaml::yaml_tag_directive_t`].
183pub type YamlTagDirectiveT = unsafe_libyaml::yaml_tag_directive_t;
184/// Alias for [`unsafe_libyaml::yaml_token_t`].
185pub type YamlTokenT = unsafe_libyaml::yaml_token_t;
186/// Alias for [`unsafe_libyaml::yaml_token_type_t`].
187pub type YamlTokenTypeT = unsafe_libyaml::yaml_token_type_t;
188/// Alias for [`unsafe_libyaml::yaml_version_directive_t`].
189pub type YamlVersionDirectiveT =
190    unsafe_libyaml::yaml_version_directive_t;
191/// Alias for [`unsafe_libyaml::yaml_write_handler_t`].
192pub type YamlWriteHandlerT = unsafe_libyaml::yaml_write_handler_t;
193
194// ── Enum-variant re-exports ───────────────────────────────────────────
195//
196// `libyml` ≤ 0.0.5 named its enum variants in PascalCase
197// (`YamlUtf8Encoding`, `YamlPlainScalarStyle`, …) and re-exported
198// them at the crate root via `pub use crate::yaml::*::*`.
199// `unsafe-libyaml` keeps the C convention — SCREAMING_SNAKE_CASE
200// (`YAML_UTF8_ENCODING`, `YAML_PLAIN_SCALAR_STYLE`, …).
201//
202// To preserve the historical bare-name surface, this section
203// declares `pub const`s that alias each PascalCase name to the
204// equivalent upstream variant. The aliases work in **value
205// position** (`yaml_emitter_set_encoding(emit, YamlUtf8Encoding)`)
206// — which is the overwhelming majority of usages — but **not as
207// refutable patterns** in `match` arms, where the upstream
208// SCREAMING_SNAKE_CASE name is required. The MIGRATION.md guide
209// documents this delta.
210//
211// The deep parser/emitter state-machine enums (`YamlParserStateT`,
212// `YamlEmitterStateT`) had ~30 variants each and were never part
213// of typical user code; their variants are reachable through the
214// upstream's snake_case path (`unsafe_libyaml::YAML_PARSE_*`).
215
216/// Re-export of upstream variants under their original SCREAMING_SNAKE_CASE
217/// names. Available for users who want to opt into the upstream surface
218/// without renaming.
219#[doc(hidden)]
220pub use unsafe_libyaml::{
221    YAML_ALIAS_EVENT, YAML_ALIAS_TOKEN, YAML_ANCHOR_TOKEN,
222    YAML_ANY_ENCODING, YAML_ANY_MAPPING_STYLE, YAML_ANY_SCALAR_STYLE,
223    YAML_ANY_SEQUENCE_STYLE, YAML_BLOCK_END_TOKEN,
224    YAML_BLOCK_ENTRY_TOKEN, YAML_BLOCK_MAPPING_START_TOKEN,
225    YAML_BLOCK_MAPPING_STYLE, YAML_BLOCK_SEQUENCE_START_TOKEN,
226    YAML_BLOCK_SEQUENCE_STYLE, YAML_COMPOSER_ERROR,
227    YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_END_TOKEN,
228    YAML_DOCUMENT_START_EVENT, YAML_DOCUMENT_START_TOKEN,
229    YAML_DOUBLE_QUOTED_SCALAR_STYLE, YAML_EMITTER_ERROR,
230    YAML_FLOW_ENTRY_TOKEN, YAML_FLOW_MAPPING_END_TOKEN,
231    YAML_FLOW_MAPPING_START_TOKEN, YAML_FLOW_MAPPING_STYLE,
232    YAML_FLOW_SEQUENCE_END_TOKEN, YAML_FLOW_SEQUENCE_START_TOKEN,
233    YAML_FLOW_SEQUENCE_STYLE, YAML_FOLDED_SCALAR_STYLE, YAML_KEY_TOKEN,
234    YAML_LITERAL_SCALAR_STYLE, YAML_MAPPING_END_EVENT,
235    YAML_MAPPING_NODE, YAML_MAPPING_START_EVENT, YAML_MEMORY_ERROR,
236    YAML_NO_ERROR, YAML_NO_EVENT, YAML_NO_NODE, YAML_NO_TOKEN,
237    YAML_PARSER_ERROR, YAML_PLAIN_SCALAR_STYLE, YAML_READER_ERROR,
238    YAML_SCALAR_EVENT, YAML_SCALAR_NODE, YAML_SCALAR_TOKEN,
239    YAML_SCANNER_ERROR, YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_NODE,
240    YAML_SEQUENCE_START_EVENT, YAML_SINGLE_QUOTED_SCALAR_STYLE,
241    YAML_STREAM_END_EVENT, YAML_STREAM_END_TOKEN,
242    YAML_STREAM_START_EVENT, YAML_STREAM_START_TOKEN,
243    YAML_TAG_DIRECTIVE_TOKEN, YAML_TAG_TOKEN, YAML_UTF16BE_ENCODING,
244    YAML_UTF16LE_ENCODING, YAML_UTF8_ENCODING, YAML_VALUE_TOKEN,
245    YAML_VERSION_DIRECTIVE_TOKEN, YAML_WRITER_ERROR,
246};
247
248// ── PascalCase const aliases for libyml ≤ 0.0.5 callers ───────────────
249
250/// Alias for [`unsafe_libyaml::YAML_ANY_SCALAR_STYLE`].
251pub const YamlAnyScalarStyle: YamlScalarStyleT =
252    unsafe_libyaml::YAML_ANY_SCALAR_STYLE;
253/// Alias for [`unsafe_libyaml::YAML_PLAIN_SCALAR_STYLE`].
254pub const YamlPlainScalarStyle: YamlScalarStyleT =
255    unsafe_libyaml::YAML_PLAIN_SCALAR_STYLE;
256/// Alias for [`unsafe_libyaml::YAML_SINGLE_QUOTED_SCALAR_STYLE`].
257pub const YamlSingleQuotedScalarStyle: YamlScalarStyleT =
258    unsafe_libyaml::YAML_SINGLE_QUOTED_SCALAR_STYLE;
259/// Alias for [`unsafe_libyaml::YAML_DOUBLE_QUOTED_SCALAR_STYLE`].
260pub const YamlDoubleQuotedScalarStyle: YamlScalarStyleT =
261    unsafe_libyaml::YAML_DOUBLE_QUOTED_SCALAR_STYLE;
262/// Alias for [`unsafe_libyaml::YAML_LITERAL_SCALAR_STYLE`].
263pub const YamlLiteralScalarStyle: YamlScalarStyleT =
264    unsafe_libyaml::YAML_LITERAL_SCALAR_STYLE;
265/// Alias for [`unsafe_libyaml::YAML_FOLDED_SCALAR_STYLE`].
266pub const YamlFoldedScalarStyle: YamlScalarStyleT =
267    unsafe_libyaml::YAML_FOLDED_SCALAR_STYLE;
268
269/// Alias for [`unsafe_libyaml::YAML_ANY_SEQUENCE_STYLE`].
270pub const YamlAnySequenceStyle: YamlSequenceStyleT =
271    unsafe_libyaml::YAML_ANY_SEQUENCE_STYLE;
272/// Alias for [`unsafe_libyaml::YAML_BLOCK_SEQUENCE_STYLE`].
273pub const YamlBlockSequenceStyle: YamlSequenceStyleT =
274    unsafe_libyaml::YAML_BLOCK_SEQUENCE_STYLE;
275/// Alias for [`unsafe_libyaml::YAML_FLOW_SEQUENCE_STYLE`].
276pub const YamlFlowSequenceStyle: YamlSequenceStyleT =
277    unsafe_libyaml::YAML_FLOW_SEQUENCE_STYLE;
278
279/// Alias for [`unsafe_libyaml::YAML_ANY_MAPPING_STYLE`].
280pub const YamlAnyMappingStyle: YamlMappingStyleT =
281    unsafe_libyaml::YAML_ANY_MAPPING_STYLE;
282/// Alias for [`unsafe_libyaml::YAML_BLOCK_MAPPING_STYLE`].
283pub const YamlBlockMappingStyle: YamlMappingStyleT =
284    unsafe_libyaml::YAML_BLOCK_MAPPING_STYLE;
285/// Alias for [`unsafe_libyaml::YAML_FLOW_MAPPING_STYLE`].
286pub const YamlFlowMappingStyle: YamlMappingStyleT =
287    unsafe_libyaml::YAML_FLOW_MAPPING_STYLE;
288
289/// Alias for [`unsafe_libyaml::YAML_ANY_ENCODING`].
290pub const YamlAnyEncoding: YamlEncodingT =
291    unsafe_libyaml::YAML_ANY_ENCODING;
292/// Alias for [`unsafe_libyaml::YAML_UTF8_ENCODING`].
293pub const YamlUtf8Encoding: YamlEncodingT =
294    unsafe_libyaml::YAML_UTF8_ENCODING;
295/// Alias for [`unsafe_libyaml::YAML_UTF16LE_ENCODING`].
296pub const YamlUtf16leEncoding: YamlEncodingT =
297    unsafe_libyaml::YAML_UTF16LE_ENCODING;
298/// Alias for [`unsafe_libyaml::YAML_UTF16BE_ENCODING`].
299pub const YamlUtf16beEncoding: YamlEncodingT =
300    unsafe_libyaml::YAML_UTF16BE_ENCODING;
301
302/// Alias for [`unsafe_libyaml::YAML_NO_ERROR`].
303pub const YamlNoError: YamlErrorTypeT = unsafe_libyaml::YAML_NO_ERROR;
304/// Alias for [`unsafe_libyaml::YAML_MEMORY_ERROR`].
305pub const YamlMemoryError: YamlErrorTypeT =
306    unsafe_libyaml::YAML_MEMORY_ERROR;
307/// Alias for [`unsafe_libyaml::YAML_READER_ERROR`].
308pub const YamlReaderError: YamlErrorTypeT =
309    unsafe_libyaml::YAML_READER_ERROR;
310/// Alias for [`unsafe_libyaml::YAML_SCANNER_ERROR`].
311pub const YamlScannerError: YamlErrorTypeT =
312    unsafe_libyaml::YAML_SCANNER_ERROR;
313/// Alias for [`unsafe_libyaml::YAML_PARSER_ERROR`].
314pub const YamlParserError: YamlErrorTypeT =
315    unsafe_libyaml::YAML_PARSER_ERROR;
316/// Alias for [`unsafe_libyaml::YAML_COMPOSER_ERROR`].
317pub const YamlComposerError: YamlErrorTypeT =
318    unsafe_libyaml::YAML_COMPOSER_ERROR;
319/// Alias for [`unsafe_libyaml::YAML_WRITER_ERROR`].
320pub const YamlWriterError: YamlErrorTypeT =
321    unsafe_libyaml::YAML_WRITER_ERROR;
322/// Alias for [`unsafe_libyaml::YAML_EMITTER_ERROR`].
323pub const YamlEmitterError: YamlErrorTypeT =
324    unsafe_libyaml::YAML_EMITTER_ERROR;
325
326/// Alias for [`unsafe_libyaml::YAML_NO_EVENT`].
327pub const YamlNoEvent: YamlEventTypeT = unsafe_libyaml::YAML_NO_EVENT;
328/// Alias for [`unsafe_libyaml::YAML_STREAM_START_EVENT`].
329pub const YamlStreamStartEvent: YamlEventTypeT =
330    unsafe_libyaml::YAML_STREAM_START_EVENT;
331/// Alias for [`unsafe_libyaml::YAML_STREAM_END_EVENT`].
332pub const YamlStreamEndEvent: YamlEventTypeT =
333    unsafe_libyaml::YAML_STREAM_END_EVENT;
334/// Alias for [`unsafe_libyaml::YAML_DOCUMENT_START_EVENT`].
335pub const YamlDocumentStartEvent: YamlEventTypeT =
336    unsafe_libyaml::YAML_DOCUMENT_START_EVENT;
337/// Alias for [`unsafe_libyaml::YAML_DOCUMENT_END_EVENT`].
338pub const YamlDocumentEndEvent: YamlEventTypeT =
339    unsafe_libyaml::YAML_DOCUMENT_END_EVENT;
340/// Alias for [`unsafe_libyaml::YAML_ALIAS_EVENT`].
341pub const YamlAliasEvent: YamlEventTypeT =
342    unsafe_libyaml::YAML_ALIAS_EVENT;
343/// Alias for [`unsafe_libyaml::YAML_SCALAR_EVENT`].
344pub const YamlScalarEvent: YamlEventTypeT =
345    unsafe_libyaml::YAML_SCALAR_EVENT;
346/// Alias for [`unsafe_libyaml::YAML_SEQUENCE_START_EVENT`].
347pub const YamlSequenceStartEvent: YamlEventTypeT =
348    unsafe_libyaml::YAML_SEQUENCE_START_EVENT;
349/// Alias for [`unsafe_libyaml::YAML_SEQUENCE_END_EVENT`].
350pub const YamlSequenceEndEvent: YamlEventTypeT =
351    unsafe_libyaml::YAML_SEQUENCE_END_EVENT;
352/// Alias for [`unsafe_libyaml::YAML_MAPPING_START_EVENT`].
353pub const YamlMappingStartEvent: YamlEventTypeT =
354    unsafe_libyaml::YAML_MAPPING_START_EVENT;
355/// Alias for [`unsafe_libyaml::YAML_MAPPING_END_EVENT`].
356pub const YamlMappingEndEvent: YamlEventTypeT =
357    unsafe_libyaml::YAML_MAPPING_END_EVENT;
358
359/// Alias for [`unsafe_libyaml::YAML_NO_NODE`].
360pub const YamlNoNode: YamlNodeTypeT = unsafe_libyaml::YAML_NO_NODE;
361/// Alias for [`unsafe_libyaml::YAML_SCALAR_NODE`].
362pub const YamlScalarNode: YamlNodeTypeT =
363    unsafe_libyaml::YAML_SCALAR_NODE;
364/// Alias for [`unsafe_libyaml::YAML_SEQUENCE_NODE`].
365pub const YamlSequenceNode: YamlNodeTypeT =
366    unsafe_libyaml::YAML_SEQUENCE_NODE;
367/// Alias for [`unsafe_libyaml::YAML_MAPPING_NODE`].
368pub const YamlMappingNode: YamlNodeTypeT =
369    unsafe_libyaml::YAML_MAPPING_NODE;
370
371// ── `libyml::success` — keep path-form imports working ────────────────
372
373/// Success/failure helpers retained for source compatibility with
374/// `libyml ≤ 0.0.5`.
375///
376/// **Migration note.** The upstream `unsafe-libyaml` crate keeps its
377/// `Success` / `Failure` structs in a private module — the values
378/// flow out of `yaml_*` calls but cannot be named at a path. The
379/// previous `libyml::success::Success` type therefore has **no
380/// nameable equivalent in the shim**; the public helpers below
381/// accept `bool` so they can still chain with the upstream return
382/// values via `.ok`.
383///
384/// Old:
385///
386/// ```ignore
387/// use libyml::success::is_success;
388/// if is_success(yaml_parser_initialize(p)) { /* … */ }
389/// ```
390///
391/// New:
392///
393/// ```ignore
394/// use libyml::success::is_success;
395/// if is_success(yaml_parser_initialize(p).ok) { /* … */ }
396/// ```
397pub mod success {
398    /// Returns `true` when the operation was successful.
399    ///
400    /// Historical `libyml ≤ 0.0.5` helper. Now takes the `ok`
401    /// flag of the upstream `Success` struct directly.
402    pub fn is_success(ok: bool) -> bool {
403        ok
404    }
405
406    /// Returns `true` when the operation failed.
407    ///
408    /// Historical `libyml ≤ 0.0.5` helper. Now takes the `ok`
409    /// flag of the upstream `Success` struct directly.
410    pub fn is_failure(ok: bool) -> bool {
411        !ok
412    }
413}
414
415// ── Path-form re-export modules ───────────────────────────────────────
416//
417// `libyml ≤ 0.0.5` exposed its surface under several sub-modules so
418// callers could do `use libyml::api::yaml_parser_set_input_string` or
419// `use libyml::yaml::YamlEventT`. The modules below restore those
420// paths verbatim by re-exporting the equivalent items from the crate
421// root (which itself re-exports from `unsafe-libyaml`). Every item is
422// inherits the `#[deprecated]` annotation through the crate root, so
423// the compiler still points at every usage during migration.
424
425/// API-surface helpers. Re-exported from the crate root for source
426/// compatibility with `libyml ≤ 0.0.5`'s
427/// [`libyml::api`](https://docs.rs/libyml/0.0.5/libyml/api/index.html)
428/// module.
429pub mod api {
430    pub use crate::{
431        yaml_alias_event_initialize, yaml_emitter_delete,
432        yaml_emitter_initialize, yaml_emitter_set_break,
433        yaml_emitter_set_canonical, yaml_emitter_set_encoding,
434        yaml_emitter_set_indent, yaml_emitter_set_output,
435        yaml_emitter_set_output_string, yaml_emitter_set_unicode,
436        yaml_emitter_set_width, yaml_mapping_end_event_initialize,
437        yaml_mapping_start_event_initialize, yaml_parser_set_encoding,
438        yaml_parser_set_input, yaml_parser_set_input_string,
439        yaml_scalar_event_initialize,
440        yaml_sequence_end_event_initialize,
441        yaml_sequence_start_event_initialize,
442        yaml_stream_end_event_initialize,
443        yaml_stream_start_event_initialize, yaml_token_delete,
444    };
445}
446
447/// Parser-decode helpers. Re-exported from the crate root for source
448/// compatibility with `libyml ≤ 0.0.5`'s
449/// [`libyml::decode`](https://docs.rs/libyml/0.0.5/libyml/decode/index.html)
450/// module.
451pub mod decode {
452    pub use crate::{yaml_parser_delete, yaml_parser_initialize};
453}
454
455/// Document-tree helpers. Re-exported from the crate root for source
456/// compatibility with `libyml ≤ 0.0.5`'s
457/// [`libyml::document`](https://docs.rs/libyml/0.0.5/libyml/document/index.html)
458/// module.
459pub mod document {
460    pub use crate::{
461        yaml_document_delete, yaml_document_end_event_initialize,
462        yaml_document_get_node, yaml_document_get_root_node,
463        yaml_document_initialize, yaml_document_start_event_initialize,
464    };
465    pub use unsafe_libyaml::{
466        yaml_document_add_mapping, yaml_document_add_scalar,
467        yaml_document_add_sequence, yaml_document_append_mapping_pair,
468        yaml_document_append_sequence_item,
469    };
470}
471
472/// Emitter dumper helpers. Re-exported from the crate root for source
473/// compatibility with `libyml ≤ 0.0.5`'s
474/// [`libyml::dumper`](https://docs.rs/libyml/0.0.5/libyml/dumper/index.html)
475/// module. **Note:** the previous releases also exposed
476/// `yaml_emitter_dump_node` / `_scalar` / `_sequence` / `_mapping` as
477/// `pub` items; the upstream keeps those private. Callers should
478/// drive emission through the public `yaml_emitter_dump` entry point.
479pub mod dumper {
480    pub use crate::{
481        yaml_emitter_close, yaml_emitter_dump, yaml_emitter_open,
482    };
483}
484
485/// Event-loader helpers. Re-exported from the crate root for source
486/// compatibility with `libyml ≤ 0.0.5`'s
487/// [`libyml::loader`](https://docs.rs/libyml/0.0.5/libyml/loader/index.html)
488/// module. **Note:** the previous releases also exposed
489/// `yaml_parser_set_composer_error` as a `pub` item; the upstream
490/// surfaces composer errors through `yaml_parser_parse` /
491/// `yaml_parser_load` directly, so callers that constructed
492/// composer errors manually need to switch to inspecting
493/// `parser.problem` after the regular parse APIs return failure.
494pub mod loader {
495    pub use crate::yaml_parser_load;
496}
497
498/// Type aliases. Re-exported from the crate root for source
499/// compatibility with `libyml ≤ 0.0.5`'s
500/// [`libyml::yaml`](https://docs.rs/libyml/0.0.5/libyml/yaml/index.html)
501/// module — all `Yaml*T` PascalCase types and `Yaml*` PascalCase enum
502/// variants land at this path too.
503pub mod yaml {
504    pub use crate::{
505        YamlAliasDataT, YamlAliasEvent, YamlAnyEncoding,
506        YamlAnyMappingStyle, YamlAnyScalarStyle, YamlAnySequenceStyle,
507        YamlBlockMappingStyle, YamlBlockSequenceStyle, YamlBreakT,
508        YamlComposerError, YamlDocumentEndEvent,
509        YamlDocumentStartEvent, YamlDocumentT,
510        YamlDoubleQuotedScalarStyle, YamlEmitterError,
511        YamlEmitterStateT, YamlEmitterT, YamlEncodingT, YamlErrorTypeT,
512        YamlEventT, YamlEventTypeT, YamlFlowMappingStyle,
513        YamlFlowSequenceStyle, YamlFoldedScalarStyle,
514        YamlLiteralScalarStyle, YamlMappingEndEvent, YamlMappingNode,
515        YamlMappingStartEvent, YamlMappingStyleT, YamlMarkT,
516        YamlMemoryError, YamlNoError, YamlNoEvent, YamlNoNode,
517        YamlNodeItemT, YamlNodePairT, YamlNodeT, YamlNodeTypeT,
518        YamlParserError, YamlParserStateT, YamlParserT,
519        YamlPlainScalarStyle, YamlReadHandlerT, YamlReaderError,
520        YamlScalarEvent, YamlScalarNode, YamlScalarStyleT,
521        YamlScannerError, YamlSequenceEndEvent, YamlSequenceNode,
522        YamlSequenceStartEvent, YamlSequenceStyleT, YamlSimpleKeyT,
523        YamlSingleQuotedScalarStyle, YamlStackT, YamlStreamEndEvent,
524        YamlStreamStartEvent, YamlTagDirectiveT, YamlTokenT,
525        YamlTokenTypeT, YamlUtf16beEncoding, YamlUtf16leEncoding,
526        YamlUtf8Encoding, YamlVersionDirectiveT, YamlWriteHandlerT,
527        YamlWriterError,
528    };
529
530    /// Alias for [`u8`]. `libyml ≤ 0.0.5` exposed YAML scalar bytes
531    /// as `yaml_char_t` (the `libyaml` C convention); preserved here
532    /// for source compatibility.
533    #[allow(non_camel_case_types)]
534    pub type yaml_char_t = u8;
535}
536
537/// **Removed in 0.0.6.** Previous releases exposed a hand-translated
538/// C-libyaml allocator surface (`yaml_malloc` / `yaml_free` /
539/// `yaml_realloc` / `yaml_strdup`). Those helpers were
540/// implementation details of the hand-translated parser, which the
541/// 0.0.6 shim deletes; the upstream `unsafe-libyaml` uses Rust's
542/// `alloc` directly. Allocate with Rust's standard primitives
543/// instead. This empty module is retained so that
544/// `use libyml::memory;` keeps resolving — every former item under
545/// it is gone.
546pub mod memory {}
547
548/// **Removed in 0.0.6 — see [`RUSTSEC-2025-0067`].** Previous
549/// releases exposed `yaml_string_extend` / `yaml_string_join`
550/// helpers under this path. The 0.0.6 shim deletes the entire
551/// hand-translated C copy that those helpers belonged to. Build
552/// strings with Rust's `Vec` / `String` instead. This empty module
553/// is retained so `use libyml::string;` keeps resolving — every
554/// former item under it is gone.
555///
556/// [`RUSTSEC-2025-0067`]: https://rustsec.org/advisories/RUSTSEC-2025-0067.html
557pub mod string {}