aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.rs
blob: d01f21eaa0d3da9c9d38c4bb990e86447e700fc3 (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
44
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 Database>,
);

impl<'d> Directory<'d>{
    pub fn child_directories(self: &'d 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(self: &mut Self) {
        unsafe {
            ffi::notmuch_directory_destroy(self.0)
        };
    }
}

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