From 918340a446ec1fe373071de2c7154b708e1bec01 Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Tue, 19 Nov 2024 11:59:49 -0500 Subject: [PATCH] docs --- src/secrets.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/secrets.rs b/src/secrets.rs index 8f8294d521b..e7f7fac8d9a 100644 --- a/src/secrets.rs +++ b/src/secrets.rs @@ -52,6 +52,13 @@ impl typesize::TypeSize for SecretString { pub struct Token(SecretString); impl Token { + /// Fetch and parses the token out of the given environment variable. + /// + /// # Errors + /// + /// Returns [`TokenError::Env`] if fetching the variable fails (see [`std::env::var`] for + /// details). May also return [`TokenError::InvalidToken`] if the token is in an invalid + /// format (see [`Token::from_str`]). pub fn from_env>(key: K) -> Result { env::var(key).map_err(TokenError::Env).and_then(|token| token.parse()) }