Struct P4

Source
pub struct P4 { /* private fields */ }

Implementations§

Source§

impl P4

Source

pub fn new() -> Self

Source

pub fn set_p4_cmd(self, custom_p4: Option<PathBuf>) -> Self

Overrides the p4 command used.

This is useful for “portable” installs (not in system path) and performance (caching the PATH lookup via where crate).

Source

pub fn set_port(self, port: Option<String>) -> Self

Overrides any P4PORT setting with the specified protocol:host:port.

Source

pub fn set_user(self, user: Option<String>) -> Self

Overrides any P4USER, USER, or USERNAME setting with the specified user name.

Source

pub fn set_password(self, password: Option<String>) -> Self

Overrides any P4PASSWD setting with the specified passwo

Source

pub fn set_client(self, client: Option<String>) -> Self

Overrides any P4CLIENT setting with the specified client name.

Source

pub fn set_retries(self, retries: Option<usize>) -> Self

Number of times a command should be retried if the network times out (takes longer than N seconds to respond to a single I/O operation) during command execution.

Source

pub fn print<'p, 'f>(&'p self, file: &'f str) -> PrintCommand<'p, 'f>

Write a depot file to standard output

Retrieve the contents of a depot file to the client’s standard output. The file is not synced. If file is specified using client syntax, Perforce uses the client view to determine the corresponding depot file.

By default, the head revision is printed. If the file argument includes a revision, the specified revision is printed. If the file argument has a revision range, then only files selected by that revision range are printed, and the highest revision in the range is printed. For details about revision specifiers, see ‘p4 help revisions’.

§Examples
let p4 = p4_cmd::P4::new();
let files = p4.print("//depot/dir/file").run().unwrap();
for file in files {
    println!("{:?}", file);
}
Source

pub fn sync<'p, 'f>(&'p self, file: &'f str) -> SyncCommand<'p, 'f>

Synchronize the client with its view of the depot

Sync updates the client workspace to reflect its current view (if it has changed) and the current contents of the depot (if it has changed). The client view maps client and depot file names and locations.

Sync adds files that are in the client view and have not been retrieved before. Sync deletes previously retrieved files that are no longer in the client view or have been deleted from the depot. Sync updates files that are still in the client view and have been updated in the depot.

By default, sync affects all files in the client workspace. If file arguments are given, sync limits its operation to those files. The file arguments can contain wildcards.

If the file argument includes a revision specifier, then the given revision is retrieved. Normally, the head revision is retrieved.

If the file argument includes a revision range specification, only files selected by the revision range are updated, and the highest revision in the range is used.

See ‘p4 help revisions’ for help specifying revisions or ranges.

Normally, sync does not overwrite workspace files that the user has manually made writable. Setting the ‘clobber’ option in the client specification disables this safety check.

§Examples
let p4 = p4_cmd::P4::new();
let dirs = p4.sync("//depot/dir/*").run().unwrap();
for dir in dirs {
    println!("{:?}", dir);
}
Source

pub fn files<'p, 'f>(&'p self, file: &'f str) -> FilesCommand<'p, 'f>

List files in the depot.

List details about specified files: depot file name, revision, file, type, change action and changelist number of the current head revision. If client syntax is used to specify the file argument, the client view mapping is used to determine the corresponding depot files.

By default, the head revision is listed. If the file argument specifies a revision, then all files at that revision are listed. If the file argument specifies a revision range, the highest revision in the range is used for each file. For details about specifying revisions, see ‘p4 help revisions’.

§Examples
let p4 = p4_cmd::P4::new();
let files = p4.files("//depot/dir/*").run().unwrap();
for file in files {
    println!("{:?}", file);
}
Source

pub fn dirs<'p, 'f, 's>(&'p self, dir: &'f str) -> DirsCommand<'p, 'f, 's>

List depot subdirectories

List directories that match the specified file pattern (dir). This command does not support the recursive wildcard (…). Use the * wildcard instead.

Perforce does not track directories individually. A path is treated as a directory if there are any undeleted files with that path as a prefix.

By default, all directories containing files are listed. If the dir argument includes a revision range, only directories containing files in the range are listed. For details about specifying file revisions, see ‘p4 help revisions’.

§Examples
let p4 = p4_cmd::P4::new();
let dirs = p4.dirs("//depot/dir/*").run().unwrap();
for dir in dirs {
    println!("{:?}", dir);
}
Source

pub fn where_<'p, 'f>(&'p self) -> WhereCommand<'p, 'f>

Show how file names are mapped by the client view

Where shows how the specified files are mapped by the client view. For each argument, three names are produced: the name in the depot, the name on the client in Perforce syntax, and the name on the client in local syntax.

If the file parameter is omitted, the mapping for all files in the current directory and below) is returned.

Note that ‘p4 where’ does not determine where any real files reside. It only displays the locations that are mapped by the client view.

§Examples
let p4 = p4_cmd::P4::new();
let files = p4.where_().file("//depot/dir/*").run().unwrap();
for file in files {
    println!("{:?}", file);
}

Trait Implementations§

Source§

impl Clone for P4

Source§

fn clone(&self) -> P4

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for P4

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for P4

§

impl RefUnwindSafe for P4

§

impl Send for P4

§

impl Sync for P4

§

impl Unpin for P4

§

impl UnwindSafe for P4

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.