libxml/lib.rs
1//! # A wrapper for libxml2
2//! This library provides an interface to a subset of the libxml API.
3//! The idea is to extend it whenever more functionality is needed.
4//! Providing a more or less complete wrapper would be too much work.
5#![deny(missing_docs)]
6// Our new methods return Result<Self, _> types
7#![allow(clippy::new_ret_no_self, clippy::result_unit_err)]
8/// Bindings to the C interface
9pub mod bindings;
10mod c_helpers;
11
12/// XML and HTML parsing
13pub mod parser;
14
15/// Manipulations on the DOM representation
16pub mod tree;
17
18/// XML Global Error Structures and Handling
19pub mod error;
20
21/// `XPath` module for global lookup in the DOM
22pub mod xpath;
23
24/// Schema Validation
25pub mod schemas;
26
27/// Read-only parallel primitives
28pub mod readonly;
29
30/// Custom input callbacks for `xmlRegisterInputCallbacks` — bundle
31/// XSLT stylesheets / RNG schemas inside the binary and serve them
32/// through a user-defined URL scheme (e.g. `embed:///foo.xsl`).
33pub mod io;
34
35/// Ensure libxml2's global parser state is initialised. Safe to call from
36/// any number of threads — internally guarded by `std::sync::Once` so the
37/// underlying `xmlInitParser()` runs exactly once. Call this before
38/// performing any libxml2 operations from application code that does
39/// *not* go through the `parser::Parser` API (which initialises lazily).
40///
41/// See libxml2's own thread-safety guidance:
42/// <https://dev.w3.org/XInclude-Test-Suite/libxml2-2.4.24/doc/threads.html>
43pub fn init_parser() {
44 use std::sync::Once;
45 static INIT: Once = Once::new();
46 INIT.call_once(|| unsafe {
47 bindings::xmlInitParser();
48 });
49}