Struct git2::RemoteCallbacks

source ·
pub struct RemoteCallbacks<'a> { /* private fields */ }
Expand description

A structure to contain the callbacks which are invoked when a repository is being updated or downloaded.

These callbacks are used to manage facilities such as authentication, transfer progress, etc.

Implementations§

source§

impl<'a> RemoteCallbacks<'a>

source

pub fn new() -> RemoteCallbacks<'a>

Creates a new set of empty callbacks

source

pub fn credentials<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(&str, Option<&str>, CredentialType) -> Result<Cred, Error> + 'a,

The callback through which to fetch credentials if required.

§Example

Prepare a callback to authenticate using the $HOME/.ssh/id_rsa SSH key, and extracting the username from the URL (i.e. git@github.com:rust-lang/git2-rs.git):

use git2::{Cred, RemoteCallbacks};
use std::env;

let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|_url, username_from_url, _allowed_types| {
  Cred::ssh_key(
    username_from_url.unwrap(),
    None,
    std::path::Path::new(&format!("{}/.ssh/id_rsa", env::var("HOME").unwrap())),
    None,
  )
});
source

pub fn transfer_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(Progress<'_>) -> bool + 'a,

The callback through which progress is monitored.

source

pub fn sideband_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(&[u8]) -> bool + 'a,

Textual progress from the remote.

Text sent over the progress side-band will be passed to this function (this is the ‘counting objects’ output).

source

pub fn update_tips<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(&str, Oid, Oid) -> bool + 'a,

Each time a reference is updated locally, the callback will be called with information about it.

source

pub fn certificate_check<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(&Cert<'_>, &str) -> Result<CertificateCheckStatus, Error> + 'a,

If certificate verification fails, then this callback will be invoked to let the caller make the final decision of whether to allow the connection to proceed.

source

pub fn push_update_reference<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(&str, Option<&str>) -> Result<(), Error> + 'a,

Set a callback to get invoked for each updated reference on a push.

The first argument to the callback is the name of the reference and the second is a status message sent by the server. If the status is Some then the push was rejected.

source

pub fn push_transfer_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(usize, usize, usize) + 'a,

The callback through which progress of push transfer is monitored

source

pub fn pack_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(PackBuilderStage, usize, usize) + 'a,

Function to call with progress information during pack building. Be aware that this is called inline with pack building operations, so performance may be affected.

source

pub fn push_negotiation<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where F: FnMut(&[PushUpdate<'_>]) -> Result<(), Error> + 'a,

The callback is called once between the negotiation step and the upload. It provides information about what updates will be performed.

Trait Implementations§

source§

impl<'a> Default for RemoteCallbacks<'a>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RemoteCallbacks<'a>

§

impl<'a> !RefUnwindSafe for RemoteCallbacks<'a>

§

impl<'a> !Send for RemoteCallbacks<'a>

§

impl<'a> !Sync for RemoteCallbacks<'a>

§

impl<'a> Unpin for RemoteCallbacks<'a>

§

impl<'a> !UnwindSafe for RemoteCallbacks<'a>

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.

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.