aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.rs
blob: 7237100ec290ce4819f2bea3e41adc03abe0f0fc (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
36
37
38
39
40
41
42
43
use std::{
    ops,
    marker,
};

use utils::{
    NewFromPtr,
};

use Database;
use Filenames;

use ffi;

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

impl<'d> Directory<'d>{
    pub fn child_directories(self: &Self) -> Filenames<'d>{
        Filenames::new(unsafe {
            ffi::notmuch_directory_get_child_directories(self.0)
        })
    }
}

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

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

unsafe impl<'d> Send for Directory<'d>{}