Mark some functions as public (#315)

Fixes #315.

Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>
This commit is contained in:
ssrlive 2022-12-02 22:35:22 +08:00 committed by GitHub
parent 72c6f6cdd0
commit 3fc7fb412c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -102,7 +102,7 @@ impl<S: Read + Write> HandshakeRole for ClientHandshake<S> {
}
/// 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<u8>, String)> {
pub fn generate_request(mut request: Request) -> Result<(Vec<u8>, String)> {
let mut req = Vec::new();
write!(
req,

View File

@ -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<Obj, Stream> {
#[derive(Debug)]
pub enum StageResult<Obj, Stream> {
/// Reading round finished.
#[allow(missing_docs)]
DoneReading { result: Obj, stream: Stream, tail: Vec<u8> },
/// Writing round finished.
DoneWriting(Stream),

View File

@ -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,

View File

@ -93,8 +93,8 @@ pub fn create_response_with_body<T>(
Ok(create_parts(request)?.body(generate_body())?)
}
// Assumes that this is a valid response
fn write_response<T>(mut w: impl io::Write, response: &HttpResponse<T>) -> Result<()> {
/// Write `response` to the stream `w`.
pub fn write_response<T>(mut w: impl io::Write, response: &HttpResponse<T>) -> Result<()> {
writeln!(
w,
"{version:?} {status}\r",