pub struct Auth {
pub token: SecretString,
}Expand description
Bearer-token authentication for Zenodo API requests.
Fields§
§token: SecretStringAPI token used for bearer authentication.
Implementations§
Source§impl Auth
impl Auth
Sourcepub const TOKEN_ENV_VAR: &'static str = "ZENODO_TOKEN"
pub const TOKEN_ENV_VAR: &'static str = "ZENODO_TOKEN"
Standard environment variable for a production Zenodo API token.
Sourcepub const SANDBOX_TOKEN_ENV_VAR: &'static str = "ZENODO_SANDBOX_TOKEN"
pub const SANDBOX_TOKEN_ENV_VAR: &'static str = "ZENODO_SANDBOX_TOKEN"
Standard environment variable for a Zenodo sandbox API token.
Sourcepub fn new(token: impl Into<String>) -> Self
pub fn new(token: impl Into<String>) -> Self
Creates a new authentication wrapper from a raw token string.
§Examples
use secrecy::ExposeSecret;
use zenodo_rs::Auth;
let auth = Auth::new("secret-token");
assert_eq!(auth.token.expose_secret(), "secret-token");Sourcepub fn from_env() -> Result<Self, ZenodoError>
pub fn from_env() -> Result<Self, ZenodoError>
Reads a production Zenodo API token from Self::TOKEN_ENV_VAR.
§Errors
Returns an error if the environment variable is missing or invalid.
Sourcepub fn from_sandbox_env() -> Result<Self, ZenodoError>
pub fn from_sandbox_env() -> Result<Self, ZenodoError>
Reads a sandbox Zenodo API token from Self::SANDBOX_TOKEN_ENV_VAR.
§Errors
Returns an error if the environment variable is missing or invalid.
Sourcepub fn from_env_var(name: &str) -> Result<Self, ZenodoError>
pub fn from_env_var(name: &str) -> Result<Self, ZenodoError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Auth
impl RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnsafeUnpin for Auth
impl UnwindSafe for Auth
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
Mutably borrows from an owned value. Read more