Struct gix::Remote

source ·
pub struct Remote<'repo> { /* private fields */ }
Expand description

A remote which represents a way to interact with hosts for remote clones of the parent repository.

Implementations§

source§

impl Remote<'_>

Builder methods

source

pub fn push_url<Url, E>(self, url: Url) -> Result<Self, Error>where Url: TryInto<Url, Error = E>, Error: From<E>,

Set the url to be used when pushing data to a remote.

source

pub fn push_url_without_url_rewrite<Url, E>( self, url: Url ) -> Result<Self, Error>where Url: TryInto<Url, Error = E>, Error: From<E>,

Set the url to be used when pushing data to a remote, without applying rewrite rules in case these could be faulty, eliminating one failure mode.

source

pub fn with_fetch_tags(self, tags: Tags) -> Self

Configure how tags should be handled when fetching from the remote.

source

pub fn with_refspecs<Spec>( self, specs: impl IntoIterator<Item = Spec>, direction: Direction ) -> Result<Self, Error>where Spec: AsRef<BStr>,

Add specs as refspecs for direction to our list if they are unique, or ignore them otherwise.

source§

impl<'repo> Remote<'repo>

Establishing connections to remote hosts (without performing a git-handshake).

source

pub fn to_connection_with_transport<T>( &self, transport: T ) -> Connection<'_, 'repo, T>where T: Transport,

Available on crate features async-network-client or blocking-network-client only.

Create a new connection using transport to communicate, with progress to indicate changes.

Note that this method expects the transport to be created by the user, which would involve the url(). It’s meant to be used when async operation is needed with runtimes of the user’s choice.

source

pub fn connect( &self, direction: Direction ) -> Result<Connection<'_, 'repo, Box<dyn Transport + Send>>, Error>

Available on (crate features async-network-client or blocking-network-client) and (crate features blocking-network-client or async-network-client-async-std) only.

Connect to the url suitable for direction and return a handle through which operations can be performed.

Note that the protocol.version configuration key affects the transport protocol used to connect, with 2 being the default.

The transport used for connection can be configured via transport_mut().configure() assuming the actually used transport is well known. If that’s not the case, the transport can be created by hand and passed to to_connection_with_transport().

source

pub fn sanitized_url_and_version( &self, direction: Direction ) -> Result<(Url, Protocol), Error>

Available on crate features async-network-client or blocking-network-client only.

Produce the sanitized URL and protocol version to use as obtained by querying the repository configuration.

This can be useful when using custom transports to allow additional configuration.

source§

impl Remote<'_>

Serialize into git-config.

source

pub fn save_to(&self, config: &mut File<'static>) -> Result<(), Error>

Save ourselves to the given config if we are a named remote or fail otherwise.

Note that all sections named remote "<name>" will be cleared of all values we are about to write, and the last remote "<name>" section will be containing all relevant values so that reloading the remote from config would yield the same in-memory state.

source

pub fn save_as_to( &mut self, name: impl Into<BString>, config: &mut File<'static> ) -> Result<(), AsError>

Forcefully set our name to name and write our state to config similar to save_to().

Note that this sets a name for anonymous remotes, but overwrites the name for those who were named before. If this name is different from the current one, the git configuration will still contain the previous name, and the caller should account for that.

source§

impl<'repo> Remote<'repo>

Access

source

pub fn name(&self) -> Option<&Name<'static>>

Return the name of this remote or None if it wasn’t persisted to disk yet.

source

pub fn repo(&self) -> &'repo Repository

Return our repository reference.

source

pub fn refspecs(&self, direction: Direction) -> &[RefSpec]

Return the set of ref-specs used for direction, which may be empty, in order of occurrence in the configuration.

source

pub fn fetch_tags(&self) -> Tags

Return how we handle tags when fetching the remote.

source

pub fn url(&self, direction: Direction) -> Option<&Url>

Return the url used for the given direction with rewrites from url.<base>.insteadOf|pushInsteadOf, unless the instance was created with one of the _without_url_rewrite() methods. For pushing, this is the remote.<name>.pushUrl or the remote.<name>.url used for fetching, and for fetching it’s the remote.<name>.url. Note that it’s possible to only have the push url set, in which case there will be no way to fetch from the remote as the push-url isn’t used for that.

source§

impl Remote<'_>

Modification

source

pub fn rewrite_urls(&mut self) -> Result<&mut Self, Error>

Read url.<base>.insteadOf|pushInsteadOf configuration variables and apply them to our urls, changing them in place.

This happens only once, and one if them may be changed even when reporting an error. If both urls fail, only the first error (for fetch urls) is reported.

source

pub fn replace_refspecs<Spec>( &mut self, specs: impl IntoIterator<Item = Spec>, direction: Direction ) -> Result<(), Error>where Spec: AsRef<BStr>,

Replace all currently set refspecs, typically from configuration, with the given specs for direction, or None if one of the input specs could not be parsed.

Trait Implementations§

source§

impl<'repo> Clone for Remote<'repo>

source§

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

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 Remote<'repo>

source§

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

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

impl<'repo> PartialEq<Remote<'repo>> for Remote<'repo>

source§

fn eq(&self, other: &Remote<'repo>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'repo> StructuralPartialEq for Remote<'repo>

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<'repo> Unpin for Remote<'repo>

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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.