ruwuma/crates/ruma-common/src/authentication.rs
Jonas Platte ee977b48f0
Make the inner type of _Custom enum variants unusable
The variant itself would be private if possible, this is the solution
closest to that.
2022-01-13 11:38:48 +01:00

27 lines
618 B
Rust

//! Common types for authentication.
use ruma_serde::StringEnum;
use crate::PrivOwnedStr;
/// Access token types.
///
/// This type can hold an arbitrary string. To check for formats that are not available as a
/// documented variant here, use its string representation, obtained through `.as_str()`.
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
pub enum TokenType {
/// Bearer token type
Bearer,
#[doc(hidden)]
_Custom(PrivOwnedStr),
}
impl TokenType {
/// Creates a string slice from this `TokenType`.
pub fn as_str(&self) -> &str {
self.as_ref()
}
}