Struct gix::Reference

source ·
pub struct Reference<'r> {
    pub inner: Reference,
    /* private fields */
}
Expand description

A reference that points to an object or reference, with access to its source repository.

Note that these are snapshots and won’t recognize if they are stale.

Fields§

§inner: Reference

The actual reference data

Implementations§

source§

impl<'repo> Reference<'repo>

Remotes

source

pub fn remote_name(&self, direction: Direction) -> Option<Name<'repo>>

Find the name of our remote for direction as configured in branch.<name>.remote|pushRemote respectively. Return None if no remote is configured.

See also Repository::branch_remote_name() for more details.

source

pub fn remote( &self, direction: Direction ) -> Option<Result<Remote<'repo>, Error>>

Find the remote along with all configuration associated with it suitable for handling this reference.

See also Repository::branch_remote() for more details.

source

pub fn remote_ref_name( &self, direction: Direction ) -> Option<Result<Cow<'_, FullNameRef>, Error>>

Return the name of this reference on the remote side.

See Repository::branch_remote_ref_name() for details.

source

pub fn remote_tracking_ref_name( &self, direction: Direction ) -> Option<Result<Cow<'_, FullNameRef>, Error>>

Return the name of the reference that tracks this reference on the remote side.

See Repository::branch_remote_tracking_ref_name() for details.

source§

impl<'repo> Reference<'repo>

source

pub fn log_iter(&self) -> Platform<'_, '_>

Return a platform for obtaining iterators over reference logs.

source

pub fn log_exists(&self) -> bool

Return true if a reflog is present for this reference.

source§

impl<'repo> Reference<'repo>

source

pub fn set_target_id( &mut self, id: impl Into<ObjectId>, reflog_message: impl Into<BString> ) -> Result<(), Error>

Set the id of this direct reference to id and use reflog_message for the reflog (if enabled in the repository).

Note that the operation will fail on symbolic references, to change their type use the lower level reference database, or if the reference was deleted or changed in the mean time. Furthermore, refrain from using this method for more than a one-off change as it creates a transaction for each invocation. If multiple reference should be changed, use Repository::edit_references() or the lower level reference database instead.

source§

impl<'repo> Reference<'repo>

source

pub fn delete(&self) -> Result<(), Error>

Delete this reference or fail if it was changed since last observed. Note that this instance remains available in memory but probably shouldn’t be used anymore.

source§

impl<'repo> Reference<'repo>

Access

source

pub fn try_id(&self) -> Option<Id<'repo>>

Returns the attached id we point to, or None if this is a symbolic ref.

source

pub fn id(&self) -> Id<'repo>

Returns the attached id we point to, or panic if this is a symbolic ref.

source

pub fn target(&self) -> TargetRef<'_>

Return the target to which this reference points to.

source

pub fn name(&self) -> &FullNameRef

Return the reference’s full name.

source

pub fn detach(self) -> Reference

Turn this instances into a stand-alone reference.

source§

impl<'repo> Reference<'repo>

Peeling

source

pub fn peel_to_id_in_place(&mut self) -> Result<Id<'repo>, Error>

Follow all symbolic targets this reference might point to and peel the underlying object to the end of the chain, and return it.

This is useful to learn where this reference is ultimately pointing to.

source

pub fn into_fully_peeled_id(self) -> Result<Id<'repo>, Error>

Similar to peel_to_id_in_place(), but consumes this instance.

source

pub fn follow(&self) -> Option<Result<Reference<'repo>, Error>>

Follow this symbolic reference one level and return the ref it refers to.

Returns None if this is not a symbolic reference, hence the leaf of the chain.

Trait Implementations§

source§

impl<'r> Clone for Reference<'r>

source§

fn clone(&self) -> Reference<'r>

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<'repo> Debug for Reference<'repo>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'r> !RefUnwindSafe for Reference<'r>

§

impl<'r> !Send for Reference<'r>

§

impl<'r> !Sync for Reference<'r>

§

impl<'r> Unpin for Reference<'r>

§

impl<'r> !UnwindSafe for Reference<'r>

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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.