| 1 |
use std::ops::Deref; |
| 2 |
|
| 3 |
use serde::{Deserialize, Serialize}; |
| 4 |
use zbus::zvariant::Type; |
| 5 |
|
| 6 |
#[cfg(any(feature = "gtk4_wayland", feature = "gtk4_x11"))] |
| 7 |
mod gtk4; |
| 8 |
|
| 9 |
#[cfg(feature = "wayland")] |
| 10 |
mod wayland; |
| 11 |
|
| 12 |
/// A token that can be used to activate an application. |
| 13 |
/// |
| 14 |
/// No guarantees are made for the token structure. |
| 15 |
#[derive(Debug, Deserialize, Serialize, Type, PartialEq, Eq, Hash, Clone)] |
| 16 |
pub struct ActivationToken(String); |
| 17 |
|
| 18 |
impl From<String> for ActivationToken { |
| 19 |
fn from(value: String) -> Self { |
| 20 |
Self(value) |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
impl From<&str> for ActivationToken { |
| 25 |
fn from(value: &str) -> Self { |
| 26 |
Self(value.to_owned()) |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
impl From<ActivationToken> for String { |
| 31 |
fn from(value: ActivationToken) -> String { |
| 32 |
value.0 |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
impl Deref for ActivationToken { |
| 37 |
type Target = str; |
| 38 |
|
| 39 |
fn deref(&self) -> &Self::Target { |
| 40 |
self.0.as_str() |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
impl AsRef<str> for ActivationToken { |
| 45 |
fn as_ref(&self) -> &str { |
| 46 |
self.0.as_str() |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
impl std::fmt::Display for ActivationToken { |
| 51 |
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 52 |
f.write_str(self.as_ref()) |
| 53 |
} |
| 54 |
} |