aboutsummaryrefslogtreecommitdiffstats
path: root/mumlib/src
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-06-06 23:26:24 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-06-06 23:26:24 +0200
commitbe76c2aa51733a0cf495e92659fbcbe527f41149 (patch)
tree617fb1caa999c076a45233b4bedea6a78192db25 /mumlib/src
parent7fc5a1a36404ee4cbc09d20c955e6edd3d2ac523 (diff)
downloadmum-be76c2aa51733a0cf495e92659fbcbe527f41149.tar.gz
cargo fmt
Diffstat (limited to 'mumlib/src')
-rw-r--r--mumlib/src/command.rs13
-rw-r--r--mumlib/src/config.rs4
-rw-r--r--mumlib/src/error.rs10
-rw-r--r--mumlib/src/state.rs6
4 files changed, 13 insertions, 20 deletions
diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs
index 847b7fd..351d7f6 100644
--- a/mumlib/src/command.rs
+++ b/mumlib/src/command.rs
@@ -35,7 +35,7 @@ pub enum Command {
SendMessage {
message: String,
targets: Vec<MessageTarget>,
- }
+ },
}
#[derive(Debug, Deserialize, Serialize)]
@@ -64,16 +64,11 @@ pub enum CommandResponse {
},
PastMessage {
message: (String, String),
- }
+ },
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum MessageTarget {
- Channel {
- recursive: bool,
- name: String,
- },
- User {
- name: String,
- }
+ Channel { recursive: bool, name: String },
+ User { name: String },
}
diff --git a/mumlib/src/config.rs b/mumlib/src/config.rs
index 587d8d0..1bd3784 100644
--- a/mumlib/src/config.rs
+++ b/mumlib/src/config.rs
@@ -85,7 +85,7 @@ pub fn default_cfg_path() -> PathBuf {
p
}
//TODO This isn't cross platform.
- None => PathBuf::from("/etc/mumdrc")
+ None => PathBuf::from("/etc/mumdrc"),
}
}
@@ -134,7 +134,7 @@ pub fn read_cfg(path: &Path) -> Result<Config, ConfigError> {
Ok(s) => {
let toml_config: TOMLConfig = toml::from_str(&s)?;
Ok(Config::try_from(toml_config)?)
- },
+ }
Err(e) => {
if matches!(e.kind(), std::io::ErrorKind::NotFound) && !path.exists() {
warn!("Config file not found");
diff --git a/mumlib/src/error.rs b/mumlib/src/error.rs
index 459ede0..e88bd97 100644
--- a/mumlib/src/error.rs
+++ b/mumlib/src/error.rs
@@ -18,14 +18,14 @@ impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- Error::Disconnected=> write!(f, "Not connected to a server"),
- Error::AlreadyConnected=> write!(f, "Already connected to a server"),
+ Error::Disconnected => write!(f, "Not connected to a server"),
+ Error::AlreadyConnected => write!(f, "Already connected to a server"),
Error::ChannelIdentifierError(id, kind) => write!(f, "{}: {}", kind, id),
Error::InvalidServerAddr(addr, port) => {
write!(f, "Invalid server address: {}: {}", addr, port)
}
Error::InvalidUsername(username) => write!(f, "Invalid username: {}", username),
- Error::InvalidServerPassword => write!(f, "Invalid server password")
+ Error::InvalidServerPassword => write!(f, "Invalid server password"),
}
}
}
@@ -65,7 +65,9 @@ impl fmt::Display for ConfigError {
ConfigError::InvalidConfig => write!(f, "Invalid configuration"),
ConfigError::TOMLErrorSer(e) => write!(f, "Invalid TOML when serializing: {}", e),
ConfigError::TOMLErrorDe(e) => write!(f, "Invalid TOML when deserializing: {}", e),
- ConfigError::WontCreateFile => write!(f, "File does not exist but caller didn't allow creation"),
+ ConfigError::WontCreateFile => {
+ write!(f, "File does not exist but caller didn't allow creation")
+ }
ConfigError::IOError(e) => write!(f, "IO error: {}", e),
}
}
diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs
index 86cbfea..6fad332 100644
--- a/mumlib/src/state.rs
+++ b/mumlib/src/state.rs
@@ -40,11 +40,7 @@ impl Channel {
} else {
Some(0)
},
- user: if self.users.is_empty() {
- None
- } else {
- Some(0)
- },
+ user: if self.users.is_empty() { None } else { Some(0) },
users: &self.users,
}
}