pub enum Value {
Public(Option<String>),
Private(Option<String>),
}Expand description
Wraps the data for an extension as a string with access restrictions.
This is a generic way for extensions to store their data in a universal, encoded form. It is also able to indicate the intended readers for such an extension so that backends can ensure that private extension data is properly encrypted even when present in a self-encoded access token.
Some extensions have semantics where the presence alone is the stored data, so storing data is optional and storing no data is distinct from not attaching any extension instance at all.
Variants§
Public(Option<String>)
An extension that the token owner is allowed to read and interpret.
Private(Option<String>)
Identifies an extenion whose content and/or existance MUST be kept secret.
Implementations§
Source§impl Value
impl Value
Sourcepub fn public(content: Option<String>) -> Self
pub fn public(content: Option<String>) -> Self
Creates an extension whose presence and content can be unveiled by the token holder.
Anyone in possession of the token corresponding to such a grant is potentially able to read the content of a public extension.
Sourcepub fn private(content: Option<String>) -> Value
pub fn private(content: Option<String>) -> Value
Creates an extension with secret content only visible for the server.
Token issuers should take special care to protect the content and the identifier of such an extension from being interpreted or correlated by the token holder.
Sourcepub fn public_value(&self) -> Result<Option<&str>, ()>
pub fn public_value(&self) -> Result<Option<&str>, ()>
Inspect the public value.
Returns an Err if this is not a public extension, None if the extension has no value
but consists only of the key, and Some(_) otherwise.
Sourcepub fn into_public_value(self) -> Result<Option<String>, ()>
pub fn into_public_value(self) -> Result<Option<String>, ()>
Convert into the public value.
Returns an Err if this is not a public extension, None if the extension has no value
but consists only of the key, and Some(_) otherwise.