A better Rust ATProto crate
at oauth 1.3 kB view raw
1//! Common types for the jacquard implementation of atproto 2 3#![warn(missing_docs)] 4pub use cowstr::CowStr; 5pub use into_static::IntoStatic; 6pub use smol_str; 7pub use url; 8 9/// A copy-on-write immutable string type that uses [`smol_str::SmolStr`] for 10/// the "owned" variant. 11#[macro_use] 12pub mod cowstr; 13#[macro_use] 14/// Trait for taking ownership of most borrowed types in jacquard. 15pub mod into_static; 16pub mod error; 17/// HTTP client abstraction used by jacquard crates. 18pub mod http_client; 19pub mod macros; 20/// Generic session storage traits and utilities. 21pub mod session; 22/// Baseline fundamental AT Protocol data types. 23pub mod types; 24 25/// Authorization token types for XRPC requests. 26#[derive(Debug, Clone)] 27pub enum AuthorizationToken<'s> { 28 /// Bearer token (access JWT, refresh JWT to refresh the session) 29 Bearer(CowStr<'s>), 30 /// DPoP token (proof-of-possession) for OAuth 31 Dpop(CowStr<'s>), 32} 33 34impl<'s> IntoStatic for AuthorizationToken<'s> { 35 type Output = AuthorizationToken<'static>; 36 fn into_static(self) -> AuthorizationToken<'static> { 37 match self { 38 AuthorizationToken::Bearer(token) => AuthorizationToken::Bearer(token.into_static()), 39 AuthorizationToken::Dpop(token) => AuthorizationToken::Dpop(token.into_static()), 40 } 41 } 42}