| 1 | use bstrrust-analyzer cargo bstr 1.12.1 crate/::BStringrust-analyzer cargo bstr 1.12.1 bstring/BString#; |
| 2 | |
| 3 | use craterust-analyzer cargo gix-credentials 0.38.0 crate/::helperrust-analyzer cargo gix-credentials 0.38.0 helper/; |
| 4 | |
| 5 | /// The outcome of the credentials top-level functions to obtain a complete identity. |
| 6 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 7 | pub struct Outcomerust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome# { |
| 8 | /// The identity provide by the helper. |
| 9 | pub identityrust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome#identity.: gix_secrust-analyzer cargo gix-sec 0.14.0 crate/::identityrust-analyzer cargo gix-sec 0.14.0 identity/::Accountrust-analyzer cargo gix-sec 0.14.0 identity/Account#, |
| 10 | /// A handle to the action to perform next in another call to [`helper::invoke()`][crate::helper::invoke()]. |
| 11 | pub nextrust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome#next.: helperrust-analyzer cargo gix-credentials 0.38.0 helper/::NextActionrust-analyzer cargo gix-credentials 0.38.0 helper/NextAction#, |
| 12 | } |
| 13 | |
| 14 | /// The Result type used in credentials top-level functions to obtain a complete identity. |
| 15 | pub type Resultrust-analyzer cargo gix-credentials 0.38.0 protocol/Result# = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Outcomerust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome#>, Errorrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#>; |
| 16 | |
| 17 | /// The error returned top-level credential functions. |
| 18 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, thiserrorrust-analyzer cargo thiserror 2.0.18 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.18 Error:)] |
| 19 | #[allow(missing_docs)] |
| 20 | pub enum Errorrust-analyzer cargo gix-credentials 0.38.0 protocol/Error# { |
| 21 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:(transparent)] |
| 22 | UrlParserust-analyzer cargo gix-credentials 0.38.0 protocol/Error#UrlParse#(#[from] gix_urlrust-analyzer cargo gix-url 0.36.0 crate/::parserust-analyzer cargo gix-url 0.36.0 parse/::Errorrust-analyzer cargo gix-url 0.36.0 parse/Error#), |
| 23 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:("Either 'url' field or both 'protocol' and 'host' fields must be provided")] |
| 24 | UrlMissingrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#UrlMissing#, |
| 25 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:(transparent)] |
| 26 | ContextDecoderust-analyzer cargo gix-credentials 0.38.0 protocol/Error#ContextDecode#(#[from] contextrust-analyzer cargo gix-credentials 0.38.0 protocol/context/::decoderust-analyzer cargo gix-credentials 0.38.0 protocol/context/serde/decode/::Errorrust-analyzer cargo gix-credentials 0.38.0 protocol/context/serde/decode/Error#), |
| 27 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:(transparent)] |
| 28 | InvokeHelperrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#InvokeHelper#(#[from] helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Errorrust-analyzer cargo gix-credentials 0.38.0 helper/Error#), |
| 29 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:("Could not obtain identity for context: {}", { let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<u8>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); context.write_torust-analyzer cargo gix-credentials 0.38.0 protocol/context/serde/write/impl#[Context]write_to().(&mut buf).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(); Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8_lossyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8_lossy().(&buf).into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().() })] |
| 30 | IdentityMissingrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#IdentityMissing# { contextrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#IdentityMissing#context.: Contextrust-analyzer cargo gix-credentials 0.38.0 protocol/Context# }, |
| 31 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:("The handler asked to stop trying to obtain credentials")] |
| 32 | Quitrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#Quit#, |
| 33 | #[errorrust-analyzer cargo thiserror-impl 2.0.18 error:("Couldn't obtain {prompt}")] |
| 34 | Promptrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#Prompt# { promptrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#Prompt#prompt.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, sourcerust-analyzer cargo gix-credentials 0.38.0 protocol/Error#Prompt#source.: gix_promptrust-analyzer cargo gix-prompt 0.15.0 crate/::Errorrust-analyzer cargo gix-prompt 0.15.0 types/Error# }, |
| 35 | } |
| 36 | |
| 37 | /// Additional context to be passed to the credentials helper. |
| 38 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 39 | pub struct Contextrust-analyzer cargo gix-credentials 0.38.0 protocol/Context# { |
| 40 | /// The protocol over which the credential will be used (e.g., https). |
| 41 | pub protocolrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#protocol.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 42 | /// The remote hostname for a network credential. This includes the port number if one was specified (e.g., "example.com:8088"). |
| 43 | pub hostrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#host.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 44 | /// 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. |
| 45 | /// It can also be a path on the file system. |
| 46 | pub pathrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#path.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BStringrust-analyzer cargo bstr 1.12.1 bstring/BString#>, |
| 47 | /// The credential’s username, if we already have one (e.g., from a URL, the configuration, the user, or from a previously run helper). |
| 48 | pub usernamerust-analyzer cargo gix-credentials 0.38.0 protocol/Context#username.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 49 | /// The credential’s password, if we are asking it to be stored. |
| 50 | pub passwordrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#password.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 51 | /// An OAuth refresh token that may accompany a password. It is to be treated confidentially, just like the password. |
| 52 | pub oauth_refresh_tokenrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#oauth_refresh_token.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 53 | /// The expiry date of OAuth tokens as seconds from Unix epoch. |
| 54 | pub password_expiry_utcrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#password_expiry_utc.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<gix_daterust-analyzer cargo gix-date 0.15.3 crate/::SecondsSinceUnixEpochrust-analyzer cargo gix-date 0.15.3 SecondsSinceUnixEpoch#>, |
| 55 | /// When this special attribute is read by git credential, the value is parsed as a URL and treated as if its constituent |
| 56 | /// parts were read (e.g., url=<https://example.com> would behave as if |
| 57 | /// protocol=https and host=example.com had been provided). This can help callers avoid parsing URLs themselves. |
| 58 | pub urlrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#url.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BStringrust-analyzer cargo bstr 1.12.1 bstring/BString#>, |
| 59 | /// If true, the caller should stop asking for credentials immediately without calling more credential helpers in the chain. |
| 60 | pub quitrust-analyzer cargo gix-credentials 0.38.0 protocol/Context#quit.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>, |
| 61 | } |
| 62 | |
| 63 | /// Convert the outcome of a helper invocation to a helper result, assuring that the identity is complete in the process. |
| 64 | #[allow(clippy::result_large_err)] |
| 65 | pub fn helper_outcome_to_resultrust-analyzer cargo gix-credentials 0.38.0 protocol/helper_outcome_to_result().(outcome: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Outcomerust-analyzer cargo gix-credentials 0.38.0 helper/Outcome#>, action: helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Actionrust-analyzer cargo gix-credentials 0.38.0 helper/Action#) -> Resultrust-analyzer cargo gix-credentials 0.38.0 protocol/Result# { |
| 66 | match (action, outcome) { |
| 67 | (helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Actionrust-analyzer cargo gix-credentials 0.38.0 helper/Action#::Getrust-analyzer cargo gix-credentials 0.38.0 helper/Action#Get#(ctx), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#::IdentityMissingrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#IdentityMissing# { |
| 68 | contextrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#IdentityMissing#context.: ctx.redactedrust-analyzer cargo gix-credentials 0.38.0 protocol/context/access/impl#[Context]redacted().(), |
| 69 | }), |
| 70 | (helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Actionrust-analyzer cargo gix-credentials 0.38.0 helper/Action#::Getrust-analyzer cargo gix-credentials 0.38.0 helper/Action#Get#(ctx), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut outcome)) => match outcome.consume_identityrust-analyzer cargo gix-credentials 0.38.0 helper/impl#[Outcome]consume_identity().() { |
| 71 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(identity) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Outcomerust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome# { |
| 72 | identityrust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome#identity., |
| 73 | nextrust-analyzer cargo gix-credentials 0.38.0 protocol/Outcome#next.: outcome.nextrust-analyzer cargo gix-credentials 0.38.0 helper/Outcome#next., |
| 74 | })), |
| 75 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(if outcome.quitrust-analyzer cargo gix-credentials 0.38.0 helper/Outcome#quit. { |
| 76 | Errorrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#::Quitrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#Quit# |
| 77 | } else { |
| 78 | Errorrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#::IdentityMissingrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#IdentityMissing# { |
| 79 | contextrust-analyzer cargo gix-credentials 0.38.0 protocol/Error#IdentityMissing#context.: ctx.redactedrust-analyzer cargo gix-credentials 0.38.0 protocol/context/access/impl#[Context]redacted().(), |
| 80 | } |
| 81 | }), |
| 82 | }, |
| 83 | (helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Actionrust-analyzer cargo gix-credentials 0.38.0 helper/Action#::Storerust-analyzer cargo gix-credentials 0.38.0 helper/Action#Store#(_) | helperrust-analyzer cargo gix-credentials 0.38.0 helper/::Actionrust-analyzer cargo gix-credentials 0.38.0 helper/Action#::Eraserust-analyzer cargo gix-credentials 0.38.0 helper/Action#Erase#(_), _ignore) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /// |
| 88 | pub mod contextrust-analyzer cargo gix-credentials 0.38.0 protocol/context/; |