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::bindings;
use std::ffi::CStr;
#[derive(Debug)]
pub struct StructuredError(*mut bindings::_xmlError);
impl StructuredError {
pub fn from_raw(error: *mut bindings::_xmlError) -> Self {
Self { 0: error }
}
pub fn message(&self) -> &str {
let msg = unsafe { CStr::from_ptr((*self.0).message) };
msg.to_str().unwrap()
}
pub fn as_ptr(&self) -> *const bindings::_xmlError {
self.0
}
}
impl Drop for StructuredError {
fn drop(&mut self) {
unsafe { bindings::xmlResetError(self.0) }
}
}