Simplify DefaultPolicy
This commit is contained in:
parent
8069164109
commit
54458709f9
1 changed files with 4 additions and 6 deletions
|
|
@ -19,7 +19,9 @@ use symbols::tls::SelfSignedTlsCert;
|
||||||
use symbols::{Symbol, SymbolRunner};
|
use symbols::{Symbol, SymbolRunner};
|
||||||
|
|
||||||
pub trait Policy {
|
pub trait Policy {
|
||||||
fn user_name_for_host(&self, host_name: &'static str) -> String;
|
fn user_name_for_host(&self, host_name: &'static str) -> String {
|
||||||
|
host_name.split('.').rev().fold(String::new(), |result, part| if result.is_empty() { result } else { result + "_" } + part)
|
||||||
|
}
|
||||||
fn home_for_user(&self, user_name: &str) -> String {
|
fn home_for_user(&self, user_name: &str) -> String {
|
||||||
format!("/home/{}", user_name)
|
format!("/home/{}", user_name)
|
||||||
}
|
}
|
||||||
|
|
@ -27,11 +29,7 @@ pub trait Policy {
|
||||||
|
|
||||||
pub struct DefaultPolicy;
|
pub struct DefaultPolicy;
|
||||||
|
|
||||||
impl Policy for DefaultPolicy {
|
impl Policy for DefaultPolicy {}
|
||||||
fn user_name_for_host(&self, host_name: &'static str) -> String {
|
|
||||||
host_name.split('.').rev().fold(String::new(), |result, part| if result.is_empty() { result } else { result + "_" } + part)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SymbolFactory<'a, C: 'a + CommandRunner, R: 'a + SymbolRunner, P: 'a + Policy> {
|
pub struct SymbolFactory<'a, C: 'a + CommandRunner, R: 'a + SymbolRunner, P: 'a + Policy> {
|
||||||
command_runner: &'a C,
|
command_runner: &'a C,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue