gix_credentials::protocol

Struct Context

source
pub struct Context {
    pub protocol: Option<String>,
    pub host: Option<String>,
    pub path: Option<BString>,
    pub username: Option<String>,
    pub password: Option<String>,
    pub url: Option<BString>,
    pub quit: Option<bool>,
}
Expand description

Additional context to be passed to the credentials helper.

Fields§

§protocol: Option<String>

The protocol over which the credential will be used (e.g., https).

§host: Option<String>

The remote hostname for a network credential. This includes the port number if one was specified (e.g., “example.com:8088”).

§path: Option<BString>

The path with which the credential will be used. E.g., for accessing a remote https repository, this will be the repository’s path on the server. It can also be a path on the file system.

§username: Option<String>

The credential’s username, if we already have one (e.g., from a URL, the configuration, the user, or from a previously run helper).

§password: Option<String>

The credential’s password, if we are asking it to be stored.

§url: Option<BString>

When this special attribute is read by git credential, the value is parsed as a URL and treated as if its constituent parts were read (e.g., url=https://example.com would behave as if protocol=https and host=example.com had been provided). This can help callers avoid parsing URLs themselves.

§quit: Option<bool>

If true, the caller should stop asking for credentials immediately without calling more credential helpers in the chain.

Implementations§

source§

impl Context

source

pub fn to_url(&self) -> Option<BString>

Convert all relevant fields into a URL for consumption.

source

pub fn to_prompt(&self, field: &str) -> String

Compute a prompt to obtain the given value.

source§

impl Context

In-place mutation

source

pub fn destructure_url_in_place( &mut self, use_http_path: bool, ) -> Result<&mut Self, Error>

Destructure the url at our url field into parts like protocol, host, username and path and store them in our respective fields. If use_http_path is set, http paths are significant even though normally this isn’t the case.

source§

impl Context

source

pub fn write_to(&self, out: impl Write) -> Result<()>

Write ourselves to out such that from_bytes() can decode it losslessly.

source

pub fn to_bstring(&self) -> BString

Like write_to(), but writes infallibly into memory.

source§

impl Context

source

pub fn from_bytes(input: &[u8]) -> Result<Self, Error>

Decode ourselves from input which is the format written by write_to().

Trait Implementations§

source§

impl Clone for Context

source§

fn clone(&self) -> Context

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 Debug for Context

source§

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

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

impl Default for Context

source§

fn default() -> Context

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

impl From<Context> for NextAction

source§

fn from(ctx: Context) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Context

source§

fn eq(&self, other: &Context) -> bool

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

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

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

impl TryFrom<&NextAction> for Context

source§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: &NextAction) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Context

source§

impl StructuralPartialEq for Context

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

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

source§

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

source§

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.