Skip to main content

BackGroundTask

Struct BackGroundTask 

Source
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>

Source

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>

Source

pub fn get_bin(&self) -> &Path

Get the Perforce command path.

Source

pub fn set_bin(&mut self, bin: impl Into<PathBuf>) -> &mut Self

Set the Perforce command path.

Source

pub fn bin(self, bin: impl Into<PathBuf>) -> Self

Set the Perforce command path.

Source

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.

Source

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.

Source

pub fn get_global_opts(&self) -> &GlobalOpts

§Description

g-opts

See Global options.

Source

pub fn set_global_opts(&mut self, v: GlobalOpts) -> &mut Self

§Description

g-opts

See Global options.

Source

pub fn global_opts(self, v: GlobalOpts) -> Self

§Description

g-opts

See Global options.

Source

pub fn get_retries(&self) -> Option<u64>

§Description

-b retries

Maximum number of execution errors before ceasing to attempt execution. The default is 1.

Source

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.

Source

pub fn retries(self, v: u64) -> Self

§Description

-b retries

Maximum number of execution errors before ceasing to attempt execution. The default is 1.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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).

Source

pub fn get_runs(&self) -> Option<u64>

§Description

-m runCount

Maximum number of times the command is run. The default is 1.

Source

pub fn set_runs(&mut self, v: u64) -> &mut Self

§Description

-m runCount

Maximum number of times the command is run. The default is 1.

Source

pub fn runs(self, v: u64) -> Self

§Description

-m runCount

Maximum number of times the command is run. The default is 1.

Source

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

pub fn set_wait(&mut self, v: u64) -> &mut Self

§Description

-w seconds

Seconds to wait after an execution error before attempting the next execution. The default is 5.

Source

pub fn wait(self, v: u64) -> Self

§Description

-w seconds

Seconds to wait after an execution error before attempting the next execution. The default is 5.

Source§

impl BackGroundTask<CommandMode>

Source

pub fn get_command(&self) -> &str

The command string selected with -e.

Source§

impl BackGroundTask<TriggerMode>

Source

pub fn get_trigger(&self) -> &str

The trigger name selected with -t.

Trait Implementations§

Source§

impl<M: Clone> Clone for BackGroundTask<M>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M: Debug> Debug for BackGroundTask<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: Default> Default for BackGroundTask<M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<M: TaskTarget> ParameterizedSpawn<()> for BackGroundTask<M>

Source§

fn spawn_with(&mut self, (): ()) -> Result<Self::Output, Self::Error>

Spawns p4 bgtask as a child process with piped standard output and error streams; use the returned Child handle to wait for it or interact with it.

Source§

type Output = Child

Source§

type Error = Error

Source§

impl<M: ExclusiveOption> SubCommand for BackGroundTask<M>

Source§

fn name(&self) -> &str

Source§

fn inject_local_args(&self, command: &mut Command)

Source§

fn global_opts(&self) -> Option<&GlobalOpts>

Source§

fn inject_args(&self, command: &mut Command)

Source§

fn setup_command<S: AsRef<OsStr>>(&self, bin: S) -> Command

Auto Trait Implementations§

§

impl<M> Freeze for BackGroundTask<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for BackGroundTask<M>
where M: RefUnwindSafe,

§

impl<M> Send for BackGroundTask<M>
where M: Send,

§

impl<M> Sync for BackGroundTask<M>
where M: Sync,

§

impl<M> Unpin for BackGroundTask<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for BackGroundTask<M>
where M: UnsafeUnpin,

§

impl<M> UnwindSafe for BackGroundTask<M>
where M: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OutputExt for T
where T: SpawnExt<Output = Child, Error = Error>,

Source§

impl<T, I> ParameterizedOutput<I> for T
where T: ParameterizedSpawn<I, Output = Child, Error = Error>,

Source§

type Error = Error

Source§

fn output_with( &mut self, input: I, ) -> Result<Output, <T as ParameterizedOutput<I>>::Error>

Source§

impl<T> SpawnExt for T

Source§

fn spawn( &mut self, ) -> Result<<T as ParameterizedSpawn<()>>::Output, <T as ParameterizedSpawn<()>>::Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.