| 76 | } |
| 77 | |
| 78 | pub(crate) fn validate(&self) -> Result<()> { |
| 79 | for (name, value) in [("database", &self.database), ("username", &self.username)] { |
| 80 | anyhow::ensure!( |
| 81 | !value.is_empty() && !value.contains('\0'), |
| 82 | "pg_dump {name} must not be empty or contain NUL bytes" |
| 83 | ); |
| 84 | } |
| 85 | for arg in &self.args { |
| 86 | anyhow::ensure!( |
| 87 | !arg.contains('\0'), |
| 88 | "pg_dump argument must not contain NUL bytes" |
| 89 | ); |
| 90 | validate_passthrough_arg(arg)?; |
| 91 | } |
| 92 | Ok(()) |
| 93 | } |
| 94 | |
| 95 | pub(crate) fn database_ref(&self) -> &str { |
| 96 | &self.database |