Implement Debug for public types (#16)

without.crypto
Craig M. Brandenburg 8 years ago committed by Dan Burkert
parent fc92971dca
commit 15fe40a8e3
  1. 26
      src/cursor.rs
  2. 8
      src/environment.rs
  3. 20
      src/transaction.rs

@ -1,5 +1,5 @@
use libc::{c_void, size_t, c_uint};
use std::{ptr, slice};
use std::{fmt, ptr, result, slice};
use std::marker::PhantomData;
use database::Database;
@ -108,6 +108,12 @@ impl <'txn> Cursor<'txn> for RoCursor<'txn> {
}
}
impl <'txn> fmt::Debug for RoCursor<'txn> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("RoCursor").finish()
}
}
impl <'txn> Drop for RoCursor<'txn> {
fn drop(&mut self) {
unsafe { ffi::mdb_cursor_close(self.cursor) }
@ -141,6 +147,12 @@ impl <'txn> Cursor<'txn> for RwCursor<'txn> {
}
}
impl <'txn> fmt::Debug for RwCursor<'txn> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("RwCursor").finish()
}
}
impl <'txn> Drop for RwCursor<'txn> {
fn drop(&mut self) {
unsafe { ffi::mdb_cursor_close(self.cursor) }
@ -217,6 +229,12 @@ impl <'txn> Iter<'txn> {
}
}
impl <'txn> fmt::Debug for Iter<'txn> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("Iter").finish()
}
}
impl <'txn> Iterator for Iter<'txn> {
type Item = (&'txn [u8], &'txn [u8]);
@ -257,6 +275,12 @@ impl <'txn> IterDup<'txn> {
}
}
impl <'txn> fmt::Debug for IterDup<'txn> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("IterDup").finish()
}
}
impl <'txn> Iterator for IterDup<'txn> {
type Item = Iter<'txn>;

@ -1,11 +1,11 @@
use libc::{c_uint, size_t};
use std::{fmt, ptr, result};
use std::ffi::CString;
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
#[cfg(windows)]
use std::ffi::OsStr;
use std::path::Path;
use std::ptr;
use std::sync::Mutex;
use ffi;
@ -156,6 +156,12 @@ impl Environment {
unsafe impl Send for Environment {}
unsafe impl Sync for Environment {}
impl fmt::Debug for Environment {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("Environment").finish()
}
}
impl Drop for Environment {
fn drop(&mut self) {
unsafe { ffi::mdb_env_close(self.env) }

@ -1,5 +1,5 @@
use libc::{c_uint, c_void, size_t};
use std::{mem, ptr, slice};
use std::{fmt, mem, ptr, result, slice};
use std::marker::PhantomData ;
use ffi;
@ -110,6 +110,12 @@ pub struct RoTransaction<'env> {
_marker: PhantomData<&'env ()>,
}
impl <'env> fmt::Debug for RoTransaction<'env> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("RoTransaction").finish()
}
}
impl <'env> Drop for RoTransaction<'env> {
fn drop(&mut self) {
unsafe { ffi::mdb_txn_abort(self.txn) }
@ -166,6 +172,12 @@ pub struct InactiveTransaction<'env> {
_marker: PhantomData<&'env ()>,
}
impl <'env> fmt::Debug for InactiveTransaction<'env> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("InactiveTransaction").finish()
}
}
impl <'env> Drop for InactiveTransaction<'env> {
fn drop(&mut self) {
unsafe { ffi::mdb_txn_abort(self.txn) }
@ -195,6 +207,12 @@ pub struct RwTransaction<'env> {
_marker: PhantomData<&'env ()>,
}
impl <'env> fmt::Debug for RwTransaction<'env> {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
f.debug_struct("RwTransaction").finish()
}
}
impl <'env> Drop for RwTransaction<'env> {
fn drop(&mut self) {
unsafe { ffi::mdb_txn_abort(self.txn) }

Loading…
Cancel
Save