#[repr(C)]pub struct Namespace<'doc> {
pub prefix: Option<&'doc str>,
pub href: &'doc str,
}Expand description
A namespace binding (prefix → href). Lifetime-bound to the document’s arena.
prefix is None for the default namespace (xmlns="…").
§Layout
On the lean (default) build, prefix and href are &'doc str
(fat slice). Under the c-abi feature this struct is byte-exact
with libxml2’s _xmlNs as verified against libxml2 2.9.13 and
2.15.3. We do not claim layout compatibility with libxml2
versions we have not verified against; the t-upstream-layout
c-test fails the build when the installed libxml2 header
disagrees with the offsets here:
_xmlNs (64-bit), the odd duck among libxml2 structs because
`next` precedes `_private`:
xmlNs *next; // offset 0 (chain pointer)
xmlNsType type; // offset 8 (XML_LOCAL_NAMESPACE = 18)
const xmlChar *href; // offset 16
const xmlChar *prefix; // offset 24
void *_private; // offset 32
xmlDoc *context; // offset 40
// sizeof == 48We populate next via [DocumentBuilder::append_ns_def] so
xmlSearchNs can walk the per-element ns_def chain. _private
and context are zero-initialized; we don’t use them but the
slots have to exist for ABI compatibility.
Fields§
§prefix: Option<&'doc str>§href: &'doc strImplementations§
Source§impl<'doc> Namespace<'doc>
impl<'doc> Namespace<'doc>
Sourcepub fn prefix(&self) -> Option<&'doc str>
pub fn prefix(&self) -> Option<&'doc str>
Namespace prefix ("xlink", etc.), or None for the default
namespace declaration (xmlns="...").
Prefer this method over direct ns.prefix field access.
On the lean rlib build it just returns the field; on the
c-abi build the storage type changes to a thin
NUL-terminated ArenaCStr and this method handles the
conversion.