diff options
author | Tim Oram <dev@mitmaro.ca> | 2020-09-17 10:45:49 -0230 |
---|---|---|
committer | Tim Oram <dev@mitmaro.ca> | 2020-09-17 22:01:14 -0230 |
commit | c6dbcc6017a7a1b343a585729239ad52ccb6ceba (patch) | |
tree | 5f27828bc435ef9eed85ebd835d55418985c07cb /src/process/handle_input_result.rs | |
parent | 10d797ebf3910f45f6ed3cd01573e531f388f31d (diff) |
Move error handling to process module
The error handling module needed to have state provided to it from other
modules, which meant that the other modules needed to understand how the
error module worked. This was awkward and fragile. This moves the error
handling code into the process module and makes it a global system. This
has the advantage of not requiring tracking of the previous state and
allows for the removal of the HandleInputResult struct.
Diffstat (limited to 'src/process/handle_input_result.rs')
-rw-r--r-- | src/process/handle_input_result.rs | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/process/handle_input_result.rs b/src/process/handle_input_result.rs deleted file mode 100644 index 9f63ee6..0000000 --- a/src/process/handle_input_result.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::input::Input; -use crate::process::exit_status::ExitStatus; -use crate::process::state::State; - -#[derive(Debug, PartialEq)] -pub struct HandleInputResult { - pub(super) exit_status: Option<ExitStatus>, - pub(super) input: Input, - pub(super) state: Option<State>, -} - -impl HandleInputResult { - pub(crate) const fn new(input: Input) -> Self { - Self { - exit_status: None, - input, - state: None, - } - } -} - -pub struct HandleInputResultBuilder { - handle_input: HandleInputResult, -} - -impl HandleInputResultBuilder { - pub(crate) const fn new(input: Input) -> Self { - Self { - handle_input: HandleInputResult { - exit_status: None, - input, - state: None, - }, - } - } - - pub(crate) const fn exit_status(mut self, status: ExitStatus) -> Self { - self.handle_input.exit_status = Some(status); - self - } - - #[allow(clippy::missing_const_for_fn)] - pub(crate) fn state(mut self, new_state: State) -> Self { - self.handle_input.state = Some(new_state); - self - } - - #[allow(clippy::missing_const_for_fn)] - pub(crate) fn build(self) -> HandleInputResult { - self.handle_input - } -} |