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

ambee/giterated

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

woo

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨2d48bc0

⁨src/messages/discovery.rs⁩ - ⁨959⁩ bytes
Raw
1 use chrono::{DateTime, Utc};
2 use serde::{Deserialize, Serialize};
3
4 use crate::model::discovery::DiscoveryItem;
5
6 use super::InstanceAuthenticated;
7
8 #[derive(Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
9 pub struct DiscoveryMessage {
10 pub message: InstanceAuthenticated<DiscoveryMessageKind>,
11 }
12
13 #[derive(Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
14 pub enum DiscoveryMessageKind {
15 Offer(DiscoveryOffer),
16 Request(DiscoveryRequest),
17 Discoveries(Discoveries),
18 }
19
20 #[derive(Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
21 pub struct DiscoveryOffer {
22 pub earliest: DateTime<Utc>,
23 pub hashes: Vec<u128>,
24 }
25
26 #[derive(Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
27 pub struct DiscoveryRequest {
28 pub since: DateTime<Utc>,
29 pub hashes: Vec<u128>,
30 }
31
32 #[derive(Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
33 pub struct Discoveries {
34 pub discoveries: Vec<DiscoveryItem>,
35 }
36