1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use super::SchemaParserContext;
use crate::bindings;
use crate::error::StructuredError;
pub struct Schema(*mut bindings::_xmlSchema);
impl Schema {
pub fn from_parser(parser: &mut SchemaParserContext) -> Result<Self, Vec<StructuredError>> {
let raw = unsafe { bindings::xmlSchemaParse(parser.as_ptr()) };
if raw.is_null() {
Err(parser.drain_errors())
} else {
Ok(Self { 0: raw })
}
}
pub fn as_ptr(&self) -> *mut bindings::_xmlSchema {
self.0
}
}
impl Drop for Schema {
fn drop(&mut self) {
unsafe { bindings::xmlSchemaFree(self.0) }
}
}