-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf99f85
commit 764e0b1
Showing
5 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::ops::Deref; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use zbus::zvariant::Type; | ||
|
||
/// A token that can be used to activate an application. | ||
/// | ||
/// No guarantees are made for the token structure. | ||
#[derive(Debug, Deserialize, Serialize, Type, PartialEq, Eq, Hash, Clone)] | ||
pub struct ActivationToken(String); | ||
|
||
impl From<String> for ActivationToken { | ||
fn from(value: String) -> Self { | ||
ActivationToken(value) | ||
} | ||
} | ||
|
||
impl From<ActivationToken> for String { | ||
fn from(value: ActivationToken) -> String { | ||
value.0 | ||
} | ||
} | ||
|
||
impl Deref for ActivationToken { | ||
type Target = str; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
self.0.as_str() | ||
} | ||
} | ||
|
||
impl AsRef<str> for ActivationToken { | ||
fn as_ref(&self) -> &str { | ||
self.0.as_str() | ||
} | ||
} | ||
|
||
impl std::fmt::Display for ActivationToken { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.write_str(self.as_ref()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters