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

ambee/giterated

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

Refactor handshake messages

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨6c50283

Showing ⁨⁨5⁩ changed files⁩ with ⁨⁨25⁩ insertions⁩ and ⁨⁨33⁩ deletions⁩

src/connection/handshake.rs

View file
@@ -3,11 +3,10 @@ use std::{str::FromStr, sync::atomic::Ordering};
3 3 use anyhow::Error;
4 4 use semver::Version;
5 5
6 use crate::model::authenticated::MessageHandler;
7 6 use crate::{
8 7 connection::ConnectionError,
9 handshake::{HandshakeFinalize, HandshakeResponse, InitiateHandshake},
10 model::authenticated::{AuthenticatedInstance, Message, NetworkMessage, State},
8 messages::handshake::{HandshakeFinalize, HandshakeResponse, InitiateHandshake},
9 model::authenticated::{AuthenticatedInstance, Message, MessageHandler, NetworkMessage, State},
11 10 validate_version,
12 11 };
13 12

src/lib.rs

View file
@@ -5,7 +5,6 @@ use semver::{Version, VersionReq};
5 5 pub mod authentication;
6 6 pub mod backend;
7 7 pub mod connection;
8 pub mod handshake;
9 8 pub mod messages;
10 9 pub mod model;
11 10

src/messages/handshake.rs

View file
@@ -0,0 +1,22 @@
1 use semver::Version;
2 use serde::{Deserialize, Serialize};
3
4 use crate::model::instance::Instance;
5
6 /// Sent by the initiator of a new inter-daemon connection.
7 #[derive(Clone, Serialize, Deserialize)]
8 pub struct InitiateHandshake {
9 pub version: Version,
10 }
11
12 /// Sent in response to [`InitiateHandshake`]
13 #[derive(Clone, Serialize, Deserialize)]
14 pub struct HandshakeResponse {
15 pub identity: Instance,
16 pub version: Version,
17 }
18
19 #[derive(Clone, Serialize, Deserialize)]
20 pub struct HandshakeFinalize {
21 pub success: bool,
22 }

src/messages/mod.rs

View file
@@ -5,6 +5,7 @@ use crate::model::user::User;
5 5
6 6 pub mod authentication;
7 7 pub mod discovery;
8 pub mod handshake;
8 9 pub mod issues;
9 10 pub mod repository;
10 11 pub mod user;