This commit is contained in:
Adrian Heine 2019-10-08 23:31:03 +02:00
parent 64bdf403d4
commit e060ce5a68
35 changed files with 142 additions and 236 deletions

View file

@ -16,7 +16,7 @@ pub enum NginxServerError<E: Error> {
impl From<io::Error> for NginxServerError<io::Error> {
fn from(err: io::Error) -> Self {
NginxServerError::ExecError(err)
Self::ExecError(err)
}
}
@ -29,7 +29,7 @@ impl<E: Error> Error for NginxServerError<E> {
}
fn cause(&self) -> Option<&dyn Error> {
match self {
NginxServerError::ExecError(ref e) => Some(e),
Self::ExecError(ref e) => Some(e),
_ => None,
}
}
@ -108,7 +108,7 @@ where
pub struct LocalTcpSocket(usize);
impl LocalTcpSocket {
pub fn new(x: usize) -> Self {
pub const fn new(x: usize) -> Self {
Self(x)
}
}
@ -130,12 +130,12 @@ impl<'a, C: CommandRunner> NginxServer<'a, C, String, PathBuf> {
target
),
);
NginxServer::new(domain, content, command_runner)
Self::new(domain, content, command_runner)
}
pub fn new_proxy<S: SocketSpec, STATIC: AsRef<Path>>(
domain: &'a str,
socket_path: S,
socket_path: &'_ S,
static_path: STATIC,
command_runner: &'a C,
) -> Self {
@ -163,7 +163,7 @@ location @proxy {{
proxy_content
),
);
NginxServer::new(domain, content, command_runner)
Self::new(domain, content, command_runner)
}
pub fn new_php<SOCKET: AsRef<Path>, STATIC: AsRef<Path>>(
@ -177,7 +177,7 @@ location @proxy {{
domain,
&(php_server_config_snippet(socket_path, static_path) + additional_config),
);
NginxServer::new(domain, content, command_runner)
Self::new(domain, content, command_runner)
}
pub fn new_static<S: AsRef<Path>>(
@ -195,7 +195,7 @@ location @proxy {{
static_path.as_ref().to_str().unwrap()
),
);
NginxServer::new(domain, content, command_runner)
Self::new(domain, content, command_runner)
}
pub fn new(domain: &'a str, content: String, command_runner: &'a C) -> Self {
@ -207,7 +207,7 @@ location @proxy {{
}
}
impl<'a, C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> Symbol for NginxServer<'a, C, T, P> {
impl<C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> Symbol for NginxServer<'_, C, T, P> {
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
if !self.file.target_reached()? {
return Ok(false);
@ -239,9 +239,7 @@ impl<'a, C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> Symbol for NginxServer
}
}
impl<'a, C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> fmt::Display
for NginxServer<'a, C, T, P>
{
impl<C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> fmt::Display for NginxServer<'_, C, T, P> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Nginx server config")
}