src/client/backup_repo.rs: implement Display trait

This commit is contained in:
Dietmar Maurer 2019-03-13 09:57:36 +01:00
parent d0a03d40ce
commit 874acb7039

View File

@ -5,6 +5,7 @@ use crate::api_schema::*;
use std::sync::Arc; use std::sync::Arc;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use std::fmt;
lazy_static! { lazy_static! {
/// Regular expression to parse repository URLs /// Regular expression to parse repository URLs
@ -68,15 +69,16 @@ impl BackupRepository {
pub fn store(&self) -> &str { pub fn store(&self) -> &str {
&self.store &self.store
} }
}
pub fn to_string(&self) -> String {
impl fmt::Display for BackupRepository {
if let Some(ref user) = self.user { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
return format!("{}@{}:{}", user, self.host(), self.store); if let Some(ref user) = self.user {
} else if let Some(ref host) = self.host { write!(f, "{}@{}:{}", user, self.host(), self.store)
return format!("{}:{}", host, self.store); } else if let Some(ref host) = self.host {
} write!(f, "{}:{}", host, self.store)
self.store.to_owned() } else {
} write!(f, "{}", self.store)
}
}
} }