trivial: move MIN_READ to input_buffer

pull/7/head
Alexey Galakhov 8 years ago
parent e63f594a14
commit 422f7bbc45
  1. 4
      src/handshake/client.rs
  2. 3
      src/input_buffer.rs
  3. 10
      src/protocol/frame/mod.rs

@ -7,7 +7,7 @@ use httparse;
use httparse::Status; use httparse::Status;
use url::Url; use url::Url;
use input_buffer::InputBuffer; use input_buffer::{InputBuffer, MIN_READ};
use error::{Error, Result}; use error::{Error, Result};
use super::{ use super::{
Headers, Headers,
@ -20,8 +20,6 @@ use protocol::{
WebSocket, Role, WebSocket, Role,
}; };
const MIN_READ: usize = 4096;
/// Client request. /// Client request.
pub struct Request { pub struct Request {
pub url: Url, pub url: Url,

@ -4,6 +4,9 @@ use bytes::{Buf, BufMut};
/// A FIFO buffer for reading packets from network. /// A FIFO buffer for reading packets from network.
pub struct InputBuffer(Cursor<Vec<u8>>); pub struct InputBuffer(Cursor<Vec<u8>>);
/// The minimum read size.
pub const MIN_READ: usize = 4096;
/// Size limit error. /// Size limit error.
pub struct SizeLimit; pub struct SizeLimit;

@ -6,15 +6,13 @@ pub use self::frame::Frame;
use std::io::{Read, Write}; use std::io::{Read, Write};
use input_buffer; use input_buffer::{InputBuffer, MIN_READ};
use error::{Error, Result}; use error::{Error, Result};
const MIN_READ: usize = 4096;
/// A reader and writer for WebSocket frames. /// A reader and writer for WebSocket frames.
pub struct FrameSocket<Stream> { pub struct FrameSocket<Stream> {
stream: Stream, stream: Stream,
in_buffer: input_buffer::InputBuffer, in_buffer: InputBuffer,
out_buffer: Vec<u8>, out_buffer: Vec<u8>,
} }
@ -23,7 +21,7 @@ impl<Stream> FrameSocket<Stream> {
pub fn new(stream: Stream) -> Self { pub fn new(stream: Stream) -> Self {
FrameSocket { FrameSocket {
stream: stream, stream: stream,
in_buffer: input_buffer::InputBuffer::with_capacity(MIN_READ), in_buffer: InputBuffer::with_capacity(MIN_READ),
out_buffer: Vec::new(), out_buffer: Vec::new(),
} }
} }
@ -31,7 +29,7 @@ impl<Stream> FrameSocket<Stream> {
pub fn from_partially_read(stream: Stream, part: Vec<u8>) -> Self { pub fn from_partially_read(stream: Stream, part: Vec<u8>) -> Self {
FrameSocket { FrameSocket {
stream: stream, stream: stream,
in_buffer: input_buffer::InputBuffer::from_partially_read(part), in_buffer: InputBuffer::from_partially_read(part),
out_buffer: Vec::new(), out_buffer: Vec::new(),
} }
} }

Loading…
Cancel
Save