[go: up one dir, main page]

Struct Proxy

Source
pub struct Proxy<'repo> { /* private fields */ }
Expand description

A stand-in to a worktree as result of a worktree iteration.

It provides access to typical worktree state, but may not actually point to a valid checkout as the latter has been moved or deleted.

Implementations§

Source§

impl Proxy<'_>

Source

pub fn base(&self) -> Result<PathBuf>

Read the location of the checkout, the base of the work tree. Note that the location might not exist.

Source

pub fn git_dir(&self) -> &Path

The git directory for the work tree, typically contained within the parent git dir.

Source

pub fn id(&self) -> &BStr

The name of the worktree, which is derived from its folder within the worktrees directory within the parent .git folder.

Source

pub fn is_locked(&self) -> bool

Return true if the worktree cannot be pruned, moved or deleted, which is useful if it is located on an external storage device.

Source

pub fn lock_reason(&self) -> Option<BString>

Provide a reason for the locking of this worktree, if it is locked at all.

Note that we squelch errors in case the file cannot be read in which case the reason is an empty string.

Source

pub fn into_repo_with_possibly_inaccessible_worktree( self, ) -> Result<Repository, Error>

Transform this proxy into a Repository while ignoring issues reading base() and ignoring that it might not exist.

Most importantly, the Repository might be initialized with a non-existing work tree directory as the checkout was removed or moved in the mean time or is unavailable for other reasons. The caller will encounter io errors if it’s used like the work tree is guaranteed to be present, but can still access a lot of information if work tree access is avoided.

Source

pub fn into_repo(self) -> Result<Repository, Error>

Like into_repo_with_possibly_inaccessible_worktree() but will fail if the base() cannot be read or if the worktree doesn’t exist.

Note that it won’t fail if the worktree doesn’t exist.

Trait Implementations§

Source§

impl<'repo> Clone for Proxy<'repo>

Source§

fn clone(&self) -> Proxy<'repo>

Returns a duplicate 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<'repo> Debug for Proxy<'repo>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'repo> Freeze for Proxy<'repo>

§

impl<'repo> !RefUnwindSafe for Proxy<'repo>

§

impl<'repo> !Send for Proxy<'repo>

§

impl<'repo> !Sync for Proxy<'repo>

§

impl<'repo> Unpin for Proxy<'repo>

§

impl<'repo> !UnwindSafe for Proxy<'repo>

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,