blob: ce219f5cb0228c5ac928e160433a649327eb6391 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
use std::ops::Drop;
use std::marker::PhantomData;
use utils::FromPtr;
use Database;
use Filenames;
use filenames::{FilenamesPtr, FilenamesOwner};
use ffi;
#[derive(Debug)]
pub(crate) struct DirectoryPtr {
pub ptr: *mut ffi::notmuch_directory_t
}
impl Drop for DirectoryPtr {
fn drop(&mut self) {
unsafe {
ffi::notmuch_directory_destroy(self.ptr)
};
}
}
impl DirectoryPtr {
pub fn child_directories(self: &Self) -> FilenamesPtr{
FilenamesPtr{
ptr: unsafe {
ffi::notmuch_directory_get_child_directories(self.ptr)
}
}
}
}
#[derive(Debug)]
pub struct Directory<'d>{
handle: DirectoryPtr,
phantom: PhantomData<&'d Database>,
}
impl<'d> FilenamesOwner for Directory<'d>{}
impl<'d> Directory<'d>{
pub fn child_directories(self: &'d Self) -> Filenames<Self>{
Filenames{
handle: self.handle.child_directories(),
phantom: PhantomData
}
}
}
impl<'d> FromPtr<*mut ffi::notmuch_directory_t> for Directory<'d> {
fn from_ptr(ptr: *mut ffi::notmuch_directory_t) -> Directory<'d> {
Directory{
handle: DirectoryPtr{ptr},
phantom: PhantomData
}
}
}
unsafe impl<'d> Send for Directory<'d>{}
unsafe impl<'d> Sync for Directory<'d>{}
|