This commit is contained in:
Nikolay Kim 2022-10-03 10:21:08 +02:00
parent 68def82d90
commit 7ce1927566
13 changed files with 21 additions and 18 deletions

View file

@ -247,7 +247,7 @@ impl ResourceDef {
let mut end = None;
let mut tail = false;
let mut rem = pattern;
let start = if pattern.starts_with('/') { 1 } else { 0 };
let start = usize::from(pattern.starts_with('/'));
let mut pattern = &pattern[start..];
elems.push(PathElement::Str('/'.to_string()));
@ -345,7 +345,7 @@ impl ResourceDef {
}
loop {
let start = if pattern.starts_with('/') { 1 } else { 0 };
let start = usize::from(pattern.starts_with('/'));
let idx = if let Some(idx) = pattern[start..].find(|c| c == '{' || c == '/') {
idx + start
} else {

View file

@ -2,7 +2,7 @@ use super::tree::Tree;
use super::{IntoPattern, Resource, ResourceDef, ResourcePath};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ResourceId(pub(crate) u16);
pub struct ResourceId(u16);
/// Resource router.
#[derive(Clone)]

View file

@ -177,7 +177,7 @@ impl<F: Filter> Filter for SslFilter<F> {
};
let (hw, lw) = self.pool.read_params().unpack();
let mut new_bytes = if self.handshake.get() { 1 } else { 0 };
let mut new_bytes = usize::from(self.handshake.get());
loop {
// make sure we've got room
let remaining = dst.remaining_mut();

View file

@ -110,7 +110,7 @@ impl<F: Filter> Filter for TlsClientFilter<F> {
return Ok((0, 0));
};
let mut new_bytes = if self.inner.handshake.get() { 1 } else { 0 };
let mut new_bytes = usize::from(self.inner.handshake.get());
loop {
// make sure we've got room
let remaining = dst.remaining_mut();

View file

@ -110,7 +110,7 @@ impl<F: Filter> Filter for TlsServerFilter<F> {
return Ok((0, 0));
};
let mut new_bytes = if self.inner.handshake.get() { 1 } else { 0 };
let mut new_bytes = usize::from(self.inner.handshake.get());
loop {
// make sure we've got room
let remaining = dst.remaining_mut();

View file

@ -438,11 +438,11 @@ impl AsyncWrite for TokioIoBoxed {
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
(*self.as_ref()).0.poll_flush(cx, false)
self.as_ref().0.poll_flush(cx, false)
}
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
(*self.as_ref()).0.poll_shutdown(cx)
self.as_ref().0.poll_shutdown(cx)
}
}

View file

@ -403,9 +403,8 @@ impl Timer {
}
}
let adj = if lvl_clk == 0 { 0 } else { 1 };
clk >>= LVL_CLK_SHIFT;
clk += adj;
clk += u64::from(lvl_clk != 0);
}
if next < u64::MAX {

View file

@ -63,14 +63,14 @@ impl Request {
#[inline]
/// Http message part of the request
pub fn head(&self) -> &RequestHead {
&*self.head
&self.head
}
#[inline]
#[doc(hidden)]
/// Mutable reference to a http message part of the request
pub fn head_mut(&mut self) -> &mut RequestHead {
&mut *self.head
&mut self.head
}
/// Request's uri.

View file

@ -67,13 +67,13 @@ impl<B> Response<B> {
#[inline]
/// Http message part of the response
pub fn head(&self) -> &ResponseHead {
&*self.head
&self.head
}
#[inline]
/// Mutable reference to a http message part of the response
pub fn head_mut(&mut self) -> &mut ResponseHead {
&mut *self.head
&mut self.head
}
/// Get the response status code

View file

@ -15,7 +15,7 @@ use super::Token;
use super::{builder::bind_addr, counter::CounterGuard};
#[derive(Clone)]
pub struct Config(pub(super) Rc<InnerServiceConfig>);
pub struct Config(Rc<InnerServiceConfig>);
pub(super) struct InnerServiceConfig {
pub(super) pool: Cell<PoolId>,
@ -37,6 +37,10 @@ impl Config {
self.0.pool.set(id);
self
}
pub(super) fn get_pool_id(&self) -> PoolId {
self.0.pool.get()
}
}
pub struct ServiceConfig(pub(super) Rc<RefCell<ServiceConfigInner>>);

View file

@ -164,7 +164,7 @@ where
match fut.await {
Ok(inner) => {
let service: BoxedServerService =
Box::new(StreamService::new(inner, cfg.0.pool.get()));
Box::new(StreamService::new(inner, cfg.get_pool_id()));
Ok(vec![(token, service)])
}
Err(_) => Err(()),

View file

@ -192,7 +192,7 @@ impl HttpRequest {
name: &str,
) -> Result<url_pkg::Url, super::error::UrlGenerationError> {
const NO_PARAMS: [&str; 0] = [];
self.url_for(name, &NO_PARAMS)
self.url_for(name, NO_PARAMS)
}
#[inline]

View file

@ -148,7 +148,7 @@ where
// when decoded, is 16 bytes in length (RFC 6455)
let mut sec_key: [u8; 16] = [0; 16];
WyRand::new().fill(&mut sec_key);
let key = base64::encode(&sec_key);
let key = base64::encode(sec_key);
headers.insert(
header::SEC_WEBSOCKET_KEY,