aboutsummaryrefslogtreecommitdiffstats
path: root/src/message.rs
blob: d77404392529c94c151421850af8af46f1c8b00f (plain) (blame)
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 std;
use std::{
    ops,
    marker,
    ptr,
};

use error::Result;

use ffi;
use utils::{
    NewFromPtr,
};
use Database;

#[derive(Debug)]
pub struct Message<'d>(
    pub(crate) *mut ffi::notmuch_message_t,
    marker::PhantomData<&'d mut Database>,
);

impl<'d> NewFromPtr<*mut ffi::notmuch_message_t> for Message<'d> {
    fn new(ptr: *mut ffi::notmuch_message_t) -> Message<'d> {
        Message(ptr, marker::PhantomData)
    }
}


impl<'d> ops::Drop for Message<'d> {
    fn drop(&mut self) {
        unsafe {
            ffi::notmuch_message_destroy(self.0)
        };
    }
}