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
use thiserror::Error;
#[derive(Debug)]
pub struct ProcessCapture {
pub stdout: String,
pub stderr: String,
}
#[derive(Error, Debug)]
pub enum TmpPostgrustError {
#[error("subprocess failed to execute")]
ExecSubprocessFailed {
#[source]
source: std::io::Error,
command: String,
},
#[error("subprocess failed to spawn")]
SpawnSubprocessFailed(#[source] std::io::Error),
#[error("initdb failed")]
InitDBFailed(ProcessCapture),
#[error("copying cached database failed")]
CopyCachedInitDBFailed(ProcessCapture),
#[error("copying cached database failed, file not found")]
CopyCachedInitDBFailedFileNotFound(#[source] std::io::Error),
#[cfg(feature = "tokio-process")]
#[error("copying cached database failed, failed to join cp process")]
CopyCachedInitDBFailedJoinError(#[source] tokio::task::JoinError),
#[error("createdb failed")]
CreateDBFailed(ProcessCapture),
#[error("failed to write postgresql.conf")]
CreateConfigFailed(#[source] std::io::Error),
#[error("failed to find temporary data directory")]
EmptyDataDirectory,
#[error("failed to create unix socket directory")]
CreateSocketDirFailed(#[source] std::io::Error),
#[error("failed to create cache directory")]
CreateCacheDirFailed(#[source] std::io::Error),
}
pub type TmpPostgrustResult<T> = Result<T, TmpPostgrustError>;