pub struct BackGroundTask<M = Unselected> { /* private fields */ }Expand description
Type-safe builder for p4 bgtask.
Run background commands or triggers on the server. The server saves the
task output to its log file; this command requires super access.
§Syntax
p4 [g-opts] bgtask [-b retries] [-d] [-i interval] [-m runCount]
[-w seconds] {-e command | -t triggerName}The M type parameter tracks the required task target at compile time:
it starts as Unselected, and one of Self::execute /
Self::trigger must be used to move into the CommandMode /
TriggerMode state before the command can be spawned. The two states
can be switched freely with the same two methods.
Implementations§
Source§impl BackGroundTask<Unselected>
impl BackGroundTask<Unselected>
Sourcepub fn new(bin: impl Into<PathBuf>, global_opts: GlobalOpts) -> Self
pub fn new(bin: impl Into<PathBuf>, global_opts: GlobalOpts) -> Self
Creates a new p4 bgtask command with no task target selected.
bin is the path to the Perforce command-line executable. Use
Self::execute or Self::trigger to select the required
-e / -t target.
Source§impl<M> BackGroundTask<M>
impl<M> BackGroundTask<M>
Sourcepub fn execute(self, command: impl Into<String>) -> BackGroundTask<CommandMode>
pub fn execute(self, command: impl Into<String>) -> BackGroundTask<CommandMode>
Selects -e command: run the given command string on the server.
This transitions into the CommandMode state, discarding any
previously selected -e / -t target; the scheduling options are
preserved.
Sourcepub fn trigger(self, name: impl Into<String>) -> BackGroundTask<TriggerMode>
pub fn trigger(self, name: impl Into<String>) -> BackGroundTask<TriggerMode>
Selects -t triggerName: run the named bgtask trigger, already defined
in the triggers table, on the server.
This transitions into the TriggerMode state, discarding any
previously selected -e / -t target; the scheduling options are
preserved.
Sourcepub fn get_global_opts(&self) -> &GlobalOpts
pub fn get_global_opts(&self) -> &GlobalOpts
Sourcepub fn set_global_opts(&mut self, v: GlobalOpts) -> &mut Self
pub fn set_global_opts(&mut self, v: GlobalOpts) -> &mut Self
Sourcepub fn global_opts(self, v: GlobalOpts) -> Self
pub fn global_opts(self, v: GlobalOpts) -> Self
Sourcepub fn get_retries(&self) -> Option<u64>
pub fn get_retries(&self) -> Option<u64>
§Description
-b retries
Maximum number of execution errors before ceasing to attempt
execution. The default is 1.
Sourcepub fn set_retries(&mut self, v: u64) -> &mut Self
pub fn set_retries(&mut self, v: u64) -> &mut Self
§Description
-b retries
Maximum number of execution errors before ceasing to attempt
execution. The default is 1.
Sourcepub fn retries(self, v: u64) -> Self
pub fn retries(self, v: u64) -> Self
§Description
-b retries
Maximum number of execution errors before ceasing to attempt
execution. The default is 1.
Sourcepub fn get_detach(&self) -> bool
pub fn get_detach(&self) -> bool
§Description
-d
Detach the client so it does not see the output of the server-side
task execution. Not allowed when the task is specified in a
startup.N configurable.
Sourcepub fn set_detach(&mut self, v: bool) -> &mut Self
pub fn set_detach(&mut self, v: bool) -> &mut Self
§Description
-d
Detach the client so it does not see the output of the server-side
task execution. Not allowed when the task is specified in a
startup.N configurable.
Sourcepub fn detach(self, v: bool) -> Self
pub fn detach(self, v: bool) -> Self
§Description
-d
Detach the client so it does not see the output of the server-side
task execution. Not allowed when the task is specified in a
startup.N configurable.
Sourcepub fn get_interval(&self) -> Option<u64>
pub fn get_interval(&self) -> Option<u64>
§Description
-i interval
Seconds between command invocations. The default is 1 second; the
maximum is 2,678,400 (the number of seconds in 31 days).
Sourcepub fn set_interval(&mut self, v: u64) -> &mut Self
pub fn set_interval(&mut self, v: u64) -> &mut Self
§Description
-i interval
Seconds between command invocations. The default is 1 second; the
maximum is 2,678,400 (the number of seconds in 31 days).
Sourcepub fn interval(self, v: u64) -> Self
pub fn interval(self, v: u64) -> Self
§Description
-i interval
Seconds between command invocations. The default is 1 second; the
maximum is 2,678,400 (the number of seconds in 31 days).
Sourcepub fn get_wait(&self) -> Option<u64>
pub fn get_wait(&self) -> Option<u64>
§Description
-w seconds
Seconds to wait after an execution error before attempting the next
execution. The default is 5.
Source§impl BackGroundTask<CommandMode>
impl BackGroundTask<CommandMode>
Sourcepub fn get_command(&self) -> &str
pub fn get_command(&self) -> &str
The command string selected with -e.
Source§impl BackGroundTask<TriggerMode>
impl BackGroundTask<TriggerMode>
Sourcepub fn get_trigger(&self) -> &str
pub fn get_trigger(&self) -> &str
The trigger name selected with -t.