Mark some functions as public (#315)

Fixes #315.

Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>
pull/326/head
ssrlive 2 years ago committed by GitHub
parent 72c6f6cdd0
commit 3fc7fb412c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/handshake/client.rs
  2. 3
      src/handshake/machine.rs
  3. 3
      src/handshake/mod.rs
  4. 4
      src/handshake/server.rs

@ -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. /// 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(); let mut req = Vec::new();
write!( write!(
req, req,

@ -1,3 +1,5 @@
//! WebSocket handshake machine.
use bytes::Buf; use bytes::Buf;
use log::*; use log::*;
use std::io::{Cursor, Read, Write}; use std::io::{Cursor, Read, Write};
@ -101,6 +103,7 @@ pub enum RoundResult<Obj, Stream> {
#[derive(Debug)] #[derive(Debug)]
pub enum StageResult<Obj, Stream> { pub enum StageResult<Obj, Stream> {
/// Reading round finished. /// Reading round finished.
#[allow(missing_docs)]
DoneReading { result: Obj, stream: Stream, tail: Vec<u8> }, DoneReading { result: Obj, stream: Stream, tail: Vec<u8> },
/// Writing round finished. /// Writing round finished.
DoneWriting(Stream), DoneWriting(Stream),

@ -2,10 +2,9 @@
pub mod client; pub mod client;
pub mod headers; pub mod headers;
pub mod machine;
pub mod server; pub mod server;
mod machine;
use std::{ use std::{
error::Error as ErrorTrait, error::Error as ErrorTrait,
fmt, fmt,

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

Loading…
Cancel
Save