pub struct Config {
pub token: Option<TokenConfig>,
pub kind: Option<Kind>,
pub host: String,
pub _non_exhaustive: (),
}
Expand description
Instructions for how to connect to a forge
Fields§
§token: Option<TokenConfig>
Access token (secret).
If left as None
, Config::forge()
will do the work
of load_default_token
.
kind: Option<Kind>
The kind of forge (ie, the protocol to speak).
Currently, None
is not supported. In the future omitting
kind
might result in auto-guessing from host
.
host: String
Hostname.
Eg, gitlab.com
, github.com
, salsa.debian.org
.
_non_exhaustive: ()
Do not specify this field. Instead, say ..Default::default()
.
New fields may be added and this will not be considered a semver break.
Implementations§
Source§impl Config
impl Config
Sourcepub fn default_token_path(&self) -> Result<PathBuf, Error>
pub fn default_token_path(&self) -> Result<PathBuf, Error>
Calculate the default path for finding a secret token.
On Unix this is ~/.config/gitforge/FORGE_EXAMPLE_ORG.KIND-token
where FORGE_EXAMPLE_ORG
is host
with dots replaced with
underscores.
Sourcepub fn load_default_token(&mut self) -> Result<&mut Self, Error>
pub fn load_default_token(&mut self) -> Result<&mut Self, Error>
Load the default token, updating this Config.
It is not normally necessary to call this, because Config::new()
will automatically laod and use the appropriate token anyway,
according to the same algorithm.
Arranges that self.token
is either Anonymous
or Value
,
by establishing a suitable default, and loading the token from
a file, as necessary.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromResponse for Twhere
T: DeserializeOwned,
impl<T> FromResponse for Twhere
T: DeserializeOwned,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more