pub struct Connection<'a, 'repo, T, P> { /* private fields */ }
Available on crate features async-network-client or blocking-network-client only.
Expand description

A type to represent an ongoing connection to a remote host, typically with the connection already established.

It can be used to perform a variety of operations with the remote without worrying about protocol details, much like a remote procedure call.

Implementations§

source§

impl<'a, 'repo, T, P> Connection<'a, 'repo, T, P>

Builder

source

pub fn with_credentials(self, helper: impl FnMut(Action) -> Result + 'a) -> Self

Set a custom credentials callback to provide credentials if the remotes require authentication.

Otherwise we will use the git configuration to perform the same task as the git credential helper program, which is calling other helper programs in succession while resorting to a prompt to obtain credentials from the user.

A custom function may also be used to prevent accessing resources with authentication.

Use the configured_credentials() method to obtain the implementation that would otherwise be used, which can be useful to proxy the default configuration and obtain information about the URLs to authenticate with.

source

pub fn with_transport_options(self, config: Box<dyn Any>) -> Self

Provide configuration to be used before the first handshake is conducted. It’s typically created by initializing it with Repository::transport_options(), which is also the default if this isn’t set explicitly. Note that all of the default configuration is created from git configuration, which can also be manipulated through overrides to affect the default configuration.

Use this method to provide transport configuration with custom backend configuration that is not configurable by other means and custom to the application at hand.

source§

impl<'a, 'repo, T, P> Connection<'a, 'repo, T, P>

Access

source

pub fn configured_credentials( &self, url: Url ) -> Result<AuthenticateFn<'static>, Error>

A utility to return a function that will use this repository’s configuration to obtain credentials, similar to what git credential is doing.

It’s meant to be used by users of the with_credentials() builder to gain access to the default way of handling credentials, which they can call as fallback.

source

pub fn remote(&self) -> &Remote<'repo>

Return the underlying remote that instantiate this connection.

source

pub fn transport_mut(&mut self) -> &mut T

Provide a mutable transport to allow interacting with it according to its actual type. Note that the caller should not call [configure()][git_protocol::transport::client::TransportWithoutIO::configure()] as we will call it automatically before performing the handshake. Instead, to bring in custom configuration, call with_transport_options().

source§

impl<'remote, 'repo, T, P> Connection<'remote, 'repo, T, P>where T: Transport, P: Progress,

source

pub fn ref_map(self, options: Options) -> Result<RefMap, Error>

List all references on the remote that have been filtered through our remote’s refspecs for fetching.

This comes in the form of all matching tips on the remote and the object they point to, along with with the local tracking branch of these tips (if available).

Note that this doesn’t fetch the objects mentioned in the tips nor does it make any change to underlying repository.

Consumption

Due to management of the transport, it’s cleanest to only use it for a single interaction. Thus it’s consumed along with the connection.

Configuration
  • gitoxide.userAgent is read to obtain the application user agent for git servers and for HTTP servers as well.
source§

impl<'remote, 'repo, T, P> Connection<'remote, 'repo, T, P>where T: Transport, P: Progress,

source

pub fn prepare_fetch( self, options: Options ) -> Result<Prepare<'remote, 'repo, T, P>, Error>

Perform a handshake with the remote and obtain a ref-map with options, and from there one Note that at this point, the transport should already be configured using the transport_mut() method, as it will be consumed here.

From there additional properties of the fetch can be adjusted to override the defaults that are configured via git-config.

Async Experimental

Note that this implementation is currently limited correctly in blocking mode only as it relies on Drop semantics to close the connection should the fetch not be performed. Furthermore, there the code doing the fetch is inherently blocking and it’s not offloaded to a thread, making this call block the executor. It’s best to unblock it by placing it into its own thread or offload it should usage in an async context be truly required.

Auto Trait Implementations§

§

impl<'a, 'repo, T, P> !RefUnwindSafe for Connection<'a, 'repo, T, P>

§

impl<'a, 'repo, T, P> !Send for Connection<'a, 'repo, T, P>

§

impl<'a, 'repo, T, P> !Sync for Connection<'a, 'repo, T, P>

§

impl<'a, 'repo, T, P> Unpin for Connection<'a, 'repo, T, P>where P: Unpin, T: Unpin, 'repo: 'a,

§

impl<'a, 'repo, T, P> !UnwindSafe for Connection<'a, 'repo, T, P>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 = mem::align_of::<T>()

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.