refactor(lib): apply unreachable_pub lint (#2400)

Closes #2390
This commit is contained in:
Taiki Endo
2021-01-15 02:57:55 +09:00
committed by GitHub
parent a15f3f7f0f
commit f0ddb66932
28 changed files with 196 additions and 185 deletions

View File

@@ -8,12 +8,12 @@ use http::Method;
use http::HeaderMap;
#[cfg(feature = "http1")]
pub fn connection_keep_alive(value: &HeaderValue) -> bool {
pub(super) fn connection_keep_alive(value: &HeaderValue) -> bool {
connection_has(value, "keep-alive")
}
#[cfg(feature = "http1")]
pub fn connection_close(value: &HeaderValue) -> bool {
pub(super) fn connection_close(value: &HeaderValue) -> bool {
connection_has(value, "close")
}
@@ -31,15 +31,15 @@ fn connection_has(value: &HeaderValue, needle: &str) -> bool {
#[cfg(feature = "http1")]
#[cfg(feature = "server")]
pub fn content_length_parse(value: &HeaderValue) -> Option<u64> {
pub(super) fn content_length_parse(value: &HeaderValue) -> Option<u64> {
value.to_str().ok().and_then(|s| s.parse().ok())
}
pub fn content_length_parse_all(headers: &HeaderMap) -> Option<u64> {
pub(super) fn content_length_parse_all(headers: &HeaderMap) -> Option<u64> {
content_length_parse_all_values(headers.get_all(CONTENT_LENGTH).into_iter())
}
pub fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>) -> Option<u64> {
pub(super) fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>) -> Option<u64> {
// If multiple Content-Length headers were sent, everything can still
// be alright if they all contain the same value, and all parse
// correctly. If not, then it's an error.
@@ -68,7 +68,7 @@ pub fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>) -> Op
#[cfg(feature = "http2")]
#[cfg(feature = "client")]
pub fn method_has_defined_payload_semantics(method: &Method) -> bool {
pub(super) fn method_has_defined_payload_semantics(method: &Method) -> bool {
match *method {
Method::GET | Method::HEAD | Method::DELETE | Method::CONNECT => false,
_ => true,
@@ -76,19 +76,19 @@ pub fn method_has_defined_payload_semantics(method: &Method) -> bool {
}
#[cfg(feature = "http2")]
pub fn set_content_length_if_missing(headers: &mut HeaderMap, len: u64) {
pub(super) fn set_content_length_if_missing(headers: &mut HeaderMap, len: u64) {
headers
.entry(CONTENT_LENGTH)
.or_insert_with(|| HeaderValue::from(len));
}
#[cfg(feature = "http1")]
pub fn transfer_encoding_is_chunked(headers: &HeaderMap) -> bool {
pub(super) fn transfer_encoding_is_chunked(headers: &HeaderMap) -> bool {
is_chunked(headers.get_all(http::header::TRANSFER_ENCODING).into_iter())
}
#[cfg(feature = "http1")]
pub fn is_chunked(mut encodings: ValueIter<'_, HeaderValue>) -> bool {
pub(super) fn is_chunked(mut encodings: ValueIter<'_, HeaderValue>) -> bool {
// chunked must always be the last encoding, according to spec
if let Some(line) = encodings.next_back() {
return is_chunked_(line);
@@ -98,7 +98,7 @@ pub fn is_chunked(mut encodings: ValueIter<'_, HeaderValue>) -> bool {
}
#[cfg(feature = "http1")]
pub fn is_chunked_(value: &HeaderValue) -> bool {
pub(super) fn is_chunked_(value: &HeaderValue) -> bool {
// chunked must always be the last encoding, according to spec
if let Ok(s) = value.to_str() {
if let Some(encoding) = s.rsplit(',').next() {
@@ -110,7 +110,7 @@ pub fn is_chunked_(value: &HeaderValue) -> bool {
}
#[cfg(feature = "http1")]
pub fn add_chunked(mut entry: http::header::OccupiedEntry<'_, HeaderValue>) {
pub(super) fn add_chunked(mut entry: http::header::OccupiedEntry<'_, HeaderValue>) {
const CHUNKED: &str = "chunked";
if let Some(line) = entry.iter_mut().next_back() {