use crate::Authentication; /// How the client is logged in to the remote. pub enum AuthenticationKind { /// With an API Ticket. Ticket(Authentication), /// With a token. Token(Token), } impl From for AuthenticationKind { fn from(auth: Authentication) -> Self { Self::Ticket(auth) } } impl From for AuthenticationKind { fn from(auth: Token) -> Self { Self::Token(auth) } } /// Data used to log in with a token. pub struct Token { /// The userid. pub userid: String, /// The api token name (usually the product abbreviation). pub prefix: String, /// The api token's value. pub value: String, } impl Token { pub fn set_auth_headers(&self, request: http::request::Builder) -> http::request::Builder { request.header( http::header::AUTHORIZATION, format!("{}={}={}", self.prefix, self.userid, self.value), ) } }