-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
417 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::time::Duration; | ||
|
||
use bytes::Bytes; | ||
|
||
#[derive(Debug, Eq, PartialEq, Clone)] | ||
pub enum CmdWaitFor { | ||
/// An empty condition. Useful for default cases or fallbacks. | ||
Nothing, | ||
/// Wait for a message on the stdout stream of the command's output. | ||
StdOutMessage { message: Bytes }, | ||
/// Wait for a message on the stderr stream of the command's output. | ||
StdErrMessage { message: Bytes }, | ||
/// Wait for a certain amount of time. | ||
Duration { length: Duration }, | ||
/// Wait for the command's exit code to be equal to the provided one. | ||
ExitCode { code: i64 }, | ||
} | ||
|
||
impl CmdWaitFor { | ||
pub fn message_on_stdout(message: impl AsRef<[u8]>) -> Self { | ||
Self::StdOutMessage { | ||
message: Bytes::from(message.as_ref().to_vec()), | ||
} | ||
} | ||
|
||
pub fn message_on_stderr(message: impl AsRef<[u8]>) -> Self { | ||
Self::StdErrMessage { | ||
message: Bytes::from(message.as_ref().to_vec()), | ||
} | ||
} | ||
|
||
pub fn exit_code(code: i64) -> Self { | ||
Self::ExitCode { code } | ||
} | ||
|
||
pub fn seconds(length: u64) -> Self { | ||
Self::Duration { | ||
length: Duration::from_secs(length), | ||
} | ||
} | ||
|
||
pub fn millis(length: u64) -> Self { | ||
Self::Duration { | ||
length: Duration::from_millis(length), | ||
} | ||
} | ||
} |
Oops, something went wrong.