Skip to content

Commit c960675

Browse files
Fix formatting
1 parent cca3bcc commit c960675

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

crates/http/src/encoding/chunked.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::io::{Read, Result, Write};
22

33
/// A reader for [HTTP Chunked transfer encoding]
4-
///
4+
///
55
/// [HTTP Chunked transfer encoding]: <https://en.wikipedia.org/wiki/Chunked_transfer_encoding>
66
pub struct Chunked<R: Read, const CHUNK_SIZE: usize = 1024> {
77
reader: R,
@@ -17,7 +17,6 @@ impl<R: Read> Chunked<R> {
1717
}
1818

1919
impl<R: Read, const CHUNK_SIZE: usize> Chunked<R, CHUNK_SIZE> {
20-
2120
/// The size of the chunks
2221
pub const CHUNK_SIZE: usize = CHUNK_SIZE;
2322

@@ -35,7 +34,7 @@ impl<R: Read, const CHUNK_SIZE: usize> Chunked<R, CHUNK_SIZE> {
3534
let mut tmpbuf: [u8; CHUNK_SIZE] = [0; CHUNK_SIZE];
3635
let n = self.reader.read(&mut tmpbuf)?;
3736
if n == 0 {
38-
return Ok(false)
37+
return Ok(false);
3938
}
4039
self.chunk.write_all(format!("{n:X}\r\n").as_bytes())?;
4140
self.chunk.write_all(&tmpbuf[0..n])?;
@@ -44,16 +43,20 @@ impl<R: Read, const CHUNK_SIZE: usize> Chunked<R, CHUNK_SIZE> {
4443
}
4544

4645
/// Returns the current chunk
47-
///
46+
///
4847
/// # NOTE
49-
/// This method returns the whole chunk, even the parts alredy
48+
/// This method returns the whole chunk, even the parts alredy
5049
/// read. If you want to know the remaining portion of the chunk
5150
/// that hasn't been polled, see [offset](Self::offset)
52-
pub fn current_chunk(&self) -> &[u8] { &self.chunk }
51+
pub fn current_chunk(&self) -> &[u8] {
52+
&self.chunk
53+
}
5354

54-
/// Returns the current offset. This is: The offset to the
55+
/// Returns the current offset. This is: The offset to the
5556
/// part of the current chunk that hasn't been read yet
56-
pub fn offset(&self) -> usize { self.offset }
57+
pub fn offset(&self) -> usize {
58+
self.offset
59+
}
5760
}
5861

5962
impl<R: Read, const CHUNK_SIZE: usize> Read for Chunked<R, CHUNK_SIZE> {
@@ -115,4 +118,4 @@ mod test {
115118
fn with_remaining() {
116119
test_chunks(&"a".repeat(SIZE + 200));
117120
}
118-
}
121+
}

crates/http/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ pub use stream::HttpStream;
3131

3232
#[doc(hidden)]
3333
pub mod prelude {
34-
pub use crate::{
35-
HttpError, HttpMethod, HttpRequest,
36-
HttpResponse, StatusCode, HttpStream,
37-
};
34+
pub use crate::{HttpError, HttpMethod, HttpRequest, HttpResponse, HttpStream, StatusCode};
3835
}
3936

4037
pub type Result<T> = std::result::Result<T, HttpError>;

crates/server/src/handler/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ use http::HttpMethod;
1616
use mime::Mime;
1717

1818
use self::{indexing::index_of, ranges::get_range_for};
19-
use crate::{log::{self, LogLevel}, request::HttpRequest, Result};
19+
use crate::{
20+
Result,
21+
log::{self, LogLevel},
22+
request::HttpRequest,
23+
};
2024

2125
/* /// HandlerFunc trait */
2226
/* /// */

crates/server/src/log.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ impl Logger for StdErrLogger {
5757
fn set_level(&mut self, level: LogLevel) {
5858
self.0 = level;
5959
}
60-
fn get_level(&self) -> LogLevel { self.0 }
60+
fn get_level(&self) -> LogLevel {
61+
self.0
62+
}
6163
}
6264

6365
#[cfg(not(debug_assertions))]

0 commit comments

Comments
 (0)