use error::{ErrorKind, Result};
use odpi::externs;
use odpi::opaque::ODPIRowid;
use std::ptr;
use util::ODPIStr;
pub struct Rowid {
inner: *mut ODPIRowid,
}
impl Rowid {
#[doc(hidden)]
pub fn inner(&self) -> *mut ODPIRowid {
self.inner
}
pub fn get_string_value(&self) -> Result<String> {
let mut value = ptr::null();
let mut value_length = 0;
try_dpi!(
externs::dpiRowid_getStringValue(self.inner, &mut value, &mut value_length),
{
if value.is_null() {
Ok("".to_string())
} else {
let res = ODPIStr::new(value, value_length);
Ok(res.into())
}
},
ErrorKind::Rowid("dpiRowid_getStringValue".to_string())
)
}
}
impl From<*mut ODPIRowid> for Rowid {
fn from(inner: *mut ODPIRowid) -> Self {
Self { inner }
}
}
impl Drop for Rowid {
fn drop(&mut self) {
if !self.inner.is_null() {
unsafe {
externs::dpiRowid_release(self.inner);
}
}
}
}