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
extern crate tesseract_sys;
use self::tesseract_sys::TessDeleteText;
use std::convert::AsRef;
use std::ffi::CStr;
use std::os::raw::c_char;
pub struct Text(*mut c_char);
unsafe impl Send for Text {}
impl Drop for Text {
fn drop(&mut self) {
unsafe { TessDeleteText(self.0) }
}
}
impl Text {
pub unsafe fn new(raw: *mut c_char) -> Self {
Self(raw)
}
}
impl AsRef<CStr> for Text {
fn as_ref(&self) -> &CStr {
unsafe { CStr::from_ptr(self.0) }
}
}