trivial: style fixes

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
pull/43/head
Alexey Galakhov 7 years ago
parent d2e3602170
commit e6ebf5ac76
  1. 4
      src/handshake/client.rs
  2. 2
      src/handshake/headers.rs
  3. 4
      src/handshake/machine.rs
  4. 2
      src/handshake/mod.rs
  5. 4
      src/protocol/frame/frame.rs
  6. 4
      src/protocol/frame/mod.rs
  7. 6
      src/protocol/mod.rs

@ -52,7 +52,7 @@ impl<'t> Request<'t> {
/// Adds a custom header to the request. /// Adds a custom header to the request.
pub fn add_header(&mut self, name: Cow<'t, str>, value: Cow<'t, str>) { pub fn add_header(&mut self, name: Cow<'t, str>, value: Cow<'t, str>) {
let mut headers = self.extra_headers.take().unwrap_or(vec![]); let mut headers = self.extra_headers.take().unwrap_or_else(Vec::new);
headers.push((name, value)); headers.push((name, value));
self.extra_headers = Some(headers); self.extra_headers = Some(headers);
} }
@ -113,7 +113,7 @@ impl<S: Read + Write> ClientHandshake<S> {
}; };
trace!("Client handshake initiated."); trace!("Client handshake initiated.");
MidHandshake { role: client, machine: machine } MidHandshake { role: client, machine }
} }
} }

@ -28,7 +28,7 @@ impl Headers {
/// Iterate over all headers with the given name. /// Iterate over all headers with the given name.
pub fn find<'headers, 'name>(&'headers self, name: &'name str) -> HeadersIter<'name, 'headers> { pub fn find<'headers, 'name>(&'headers self, name: &'name str) -> HeadersIter<'name, 'headers> {
HeadersIter { HeadersIter {
name: name, name,
iter: self.data.iter() iter: self.data.iter()
} }
} }

@ -16,14 +16,14 @@ impl<Stream> HandshakeMachine<Stream> {
/// Start reading data from the peer. /// Start reading data from the peer.
pub fn start_read(stream: Stream) -> Self { pub fn start_read(stream: Stream) -> Self {
HandshakeMachine { HandshakeMachine {
stream: stream, stream,
state: HandshakeState::Reading(InputBuffer::with_capacity(MIN_READ)), state: HandshakeState::Reading(InputBuffer::with_capacity(MIN_READ)),
} }
} }
/// Start writing data to the peer. /// Start writing data to the peer.
pub fn start_write<D: Into<Vec<u8>>>(stream: Stream, data: D) -> Self { pub fn start_write<D: Into<Vec<u8>>>(stream: Stream, data: D) -> Self {
HandshakeMachine { HandshakeMachine {
stream: stream, stream,
state: HandshakeState::Writing(Cursor::new(data.into())), state: HandshakeState::Writing(Cursor::new(data.into())),
} }
} }

@ -110,7 +110,7 @@ pub enum ProcessingResult<Stream, FinalResult> {
fn convert_key(input: &[u8]) -> Result<String, Error> { fn convert_key(input: &[u8]) -> Result<String, Error> {
// ... field is constructed by concatenating /key/ ... // ... field is constructed by concatenating /key/ ...
// ... with the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (RFC 6455) // ... with the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (RFC 6455)
const WS_GUID: &'static [u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; const WS_GUID: &[u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
let mut sha1 = Sha1::default(); let mut sha1 = Sha1::default();
sha1.input(input); sha1.input(input);
sha1.input(WS_GUID); sha1.input(WS_GUID);

@ -296,7 +296,7 @@ impl Frame {
let code = NetworkEndian::read_u16(&data[0..2]).into(); let code = NetworkEndian::read_u16(&data[0..2]).into();
data.drain(0..2); data.drain(0..2);
let text = String::from_utf8(data)?; let text = String::from_utf8(data)?;
Ok(Some(CloseFrame { code: code, reason: text.into() })) Ok(Some(CloseFrame { code, reason: text.into() }))
} }
} }
} }
@ -357,7 +357,7 @@ impl Frame {
Frame { Frame {
header: FrameHeader::default(), header: FrameHeader::default(),
payload: payload, payload,
} }
} }

@ -30,7 +30,7 @@ impl<Stream> FrameSocket<Stream> {
/// Create a new frame socket. /// Create a new frame socket.
pub fn new(stream: Stream) -> Self { pub fn new(stream: Stream) -> Self {
FrameSocket { FrameSocket {
stream: stream, stream,
in_buffer: InputBuffer::with_capacity(MIN_READ), in_buffer: InputBuffer::with_capacity(MIN_READ),
out_buffer: Vec::new(), out_buffer: Vec::new(),
header: None, header: None,
@ -40,7 +40,7 @@ impl<Stream> FrameSocket<Stream> {
/// Create a new frame socket from partially read data. /// Create a new frame socket from partially read data.
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,
in_buffer: InputBuffer::from_partially_read(part), in_buffer: InputBuffer::from_partially_read(part),
out_buffer: Vec::new(), out_buffer: Vec::new(),
header: None, header: None,

@ -116,13 +116,13 @@ impl<Stream> WebSocket<Stream> {
config: Option<WebSocketConfig> config: Option<WebSocketConfig>
) -> Self { ) -> Self {
WebSocket { WebSocket {
role: role, role,
socket: socket, socket,
state: WebSocketState::Active, state: WebSocketState::Active,
incomplete: None, incomplete: None,
send_queue: VecDeque::new(), send_queue: VecDeque::new(),
pong: None, pong: None,
config: config.unwrap_or_else(|| WebSocketConfig::default()), config: config.unwrap_or_else(WebSocketConfig::default),
} }
} }
} }

Loading…
Cancel
Save