From 3fc7fb412c3e6fdc8bdf7861104b645c9d527202 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Fri, 2 Dec 2022 22:35:22 +0800 Subject: [PATCH] Mark some functions as public (#315) Fixes #315. Co-authored-by: Daniel Abramov --- src/handshake/client.rs | 2 +- src/handshake/machine.rs | 3 +++ src/handshake/mod.rs | 3 +-- src/handshake/server.rs | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/handshake/client.rs b/src/handshake/client.rs index aaeabb7..409c193 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -102,7 +102,7 @@ impl HandshakeRole for ClientHandshake { } /// Verifies and generates a client WebSocket request from the original request and extracts a WebSocket key from it. -fn generate_request(mut request: Request) -> Result<(Vec, String)> { +pub fn generate_request(mut request: Request) -> Result<(Vec, String)> { let mut req = Vec::new(); write!( req, diff --git a/src/handshake/machine.rs b/src/handshake/machine.rs index 83dae1f..eacb4bf 100644 --- a/src/handshake/machine.rs +++ b/src/handshake/machine.rs @@ -1,3 +1,5 @@ +//! WebSocket handshake machine. + use bytes::Buf; use log::*; use std::io::{Cursor, Read, Write}; @@ -101,6 +103,7 @@ pub enum RoundResult { #[derive(Debug)] pub enum StageResult { /// Reading round finished. + #[allow(missing_docs)] DoneReading { result: Obj, stream: Stream, tail: Vec }, /// Writing round finished. DoneWriting(Stream), diff --git a/src/handshake/mod.rs b/src/handshake/mod.rs index e063d4a..f3387a4 100644 --- a/src/handshake/mod.rs +++ b/src/handshake/mod.rs @@ -2,10 +2,9 @@ pub mod client; pub mod headers; +pub mod machine; pub mod server; -mod machine; - use std::{ error::Error as ErrorTrait, fmt, diff --git a/src/handshake/server.rs b/src/handshake/server.rs index 6be3b15..bc072ce 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -93,8 +93,8 @@ pub fn create_response_with_body( Ok(create_parts(request)?.body(generate_body())?) } -// Assumes that this is a valid response -fn write_response(mut w: impl io::Write, response: &HttpResponse) -> Result<()> { +/// Write `response` to the stream `w`. +pub fn write_response(mut w: impl io::Write, response: &HttpResponse) -> Result<()> { writeln!( w, "{version:?} {status}\r",