aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 187380a..f2ce6f5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,2 +1,26 @@
-pub mod field;
+pub mod error;
+pub mod handshake;
+// pub mod field;
// pub mod transactions;
+
+use crate::error::HotlineError;
+use crate::handshake::accept_handshake;
+
+use std::net::TcpStream;
+
+/// Get the stream and act as a server. If you want to act as a client, you
+/// will have to write your own handler.
+///
+/// # Errors
+///
+/// Returns error if handshake fails or stream I/O fails
+pub fn handle_client(mut stream: TcpStream) -> Result<(), HotlineError> {
+ let handshake_request = accept_handshake(&mut stream)?;
+
+ eprintln!(
+ "Handshake successful with sub_protocol_id: 0x{:08X}, sub_version: {}",
+ handshake_request.sub_protocol_id, handshake_request.sub_version
+ );
+
+ Ok(())
+}