#![allow(dead_code)]
use std::ffi::CStr;
use std::fmt;
use libdb_sys::ffi;
#[derive(Debug)]
pub struct Error {
errno: i32,
}
impl Error {
pub fn new(errno: i32) -> Error {
Error { errno: errno }
}
pub fn errno(&self) -> i32 {
self.errno
}
pub fn as_string(&self) -> String {
unsafe {
CStr::from_ptr(ffi::db_strerror(self.errno)).to_string_lossy().into_owned()
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.as_string())
}
}
pub const DB_BUFFER_SMALL: i32 = -30999;
pub const DB_DONOTINDEX: i32 = -30998;
pub const DB_FOREIGN_CONFLICT: i32 = -30997;
pub const DB_KEYEMPTY: i32 = -30996;
pub const DB_KEYEXIST: i32 = -30995;
pub const DB_LOCK_DEADLOCK: i32 = -30994;
pub const DB_LOCK_NOTGRANTED: i32 = -30993;
pub const DB_LOG_BUFFER_FULL: i32 = -30992;
pub const DB_NOSERVER: i32 = -30991;
pub const DB_NOSERVER_HOME: i32 = -30990;
pub const DB_NOSERVER_ID: i32 = -30989;
pub const DB_NOTFOUND: i32 = -30988;
pub const DB_OLD_VERSION: i32 = -30987;
pub const DB_PAGE_NOTFOUND: i32 = -30986;
pub const DB_REP_DUPMASTER: i32 = -30985;
pub const DB_REP_HANDLE_DEAD: i32 = -30984;
pub const DB_REP_HOLDELECTION: i32 = -30983;
pub const DB_REP_IGNORE: i32 = -30982;
pub const DB_REP_ISPERM: i32 = -30981;
pub const DB_REP_JOIN_FAILURE: i32 = -30980;
pub const DB_REP_LEASE_EXPIRED: i32 = -30979;
pub const DB_REP_LOCKOUT: i32 = -30978;
pub const DB_REP_NEWSITE: i32 = -30977;
pub const DB_REP_NOTPERM: i32 = -30976;
pub const DB_REP_UNAVAIL: i32 = -30975;
pub const DB_RUNRECOVERY: i32 = -30974;
pub const DB_SECONDARY_BAD: i32 = -30973;
pub const DB_VERIFY_BAD: i32 = -30972;
pub const DB_VERSION_MISMATCH: i32 = -30971;