Struct git_repository::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
sourceimpl Remote<'_>
impl Remote<'_>
Builder methods
sourcepub fn push_url<Url, E>(self, url: Url) -> Result<Self, Error> where
Url: TryInto<Url, Error = E>,
Error: From<E>,
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.
sourceimpl<'repo> Remote<'repo>
impl<'repo> Remote<'repo>
Establishing connections to remote hosts
sourcepub fn to_connection_with_transport<T, P>(
&self,
transport: T,
progress: P
) -> Connection<'_, 'repo, T, P> where
T: Transport,
P: Progress,
Available on crate features async-network-client or blocking-network-client only.
pub fn to_connection_with_transport<T, P>(
&self,
transport: T,
progress: P
) -> Connection<'_, 'repo, T, P> where
T: Transport,
P: Progress,
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.
sourcepub fn connect<P>(
&self,
direction: Direction,
progress: P
) -> Result<Connection<'_, 'repo, Box<dyn Transport + Send>, P>, Error> where
P: Progress,
Available on (crate features async-network-client or blocking-network-client) and (crate features blocking-network-client or async-network-client-async-std) only.
pub fn connect<P>(
&self,
direction: Direction,
progress: P
) -> Result<Connection<'_, 'repo, Box<dyn Transport + Send>, P>, Error> where
P: Progress,
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.
sourceimpl Remote<'_>
impl Remote<'_>
Access
sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Return the name of this remote or None if it wasn’t persisted to disk yet.
sourcepub fn refspecs(&self, direction: Direction) -> &[RefSpec]
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.
sourcepub fn url(&self, direction: Direction) -> Option<&Url>
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.
sourceimpl Remote<'_>
impl Remote<'_>
Modification
sourcepub fn rewrite_urls(&mut self) -> Result<&mut Self, Error>
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.
Trait Implementations
sourceimpl<'repo> PartialEq<Remote<'repo>> for Remote<'repo>
impl<'repo> PartialEq<Remote<'repo>> for Remote<'repo>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more