JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Fix types

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨7eb1974

⁨giterated-models/src/authenticated.rs⁩ - ⁨903⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::{instance::Instance, user::User};
4
5 #[repr(transparent)]
6 #[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
7 pub struct UserAuthenticationToken(String);
8
9 impl From<String> for UserAuthenticationToken {
10 fn from(value: String) -> Self {
11 Self(value)
12 }
13 }
14
15 impl ToString for UserAuthenticationToken {
16 fn to_string(&self) -> String {
17 self.0.clone()
18 }
19 }
20
21 impl AsRef<str> for UserAuthenticationToken {
22 fn as_ref(&self) -> &str {
23 &self.0
24 }
25 }
26
27 #[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
28 pub struct InstanceSignature(pub Vec<u8>);
29
30 impl AsRef<[u8]> for InstanceSignature {
31 fn as_ref(&self) -> &[u8] {
32 &self.0
33 }
34 }
35
36 #[derive(Debug, Serialize, Deserialize)]
37 pub struct UserTokenMetadata {
38 pub user: User,
39 pub generated_for: Instance,
40 pub exp: u64,
41 }
42