1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Readability fixes for cargo clippy

This commit is contained in:
NG (Graham)
2025-09-03 22:33:26 -04:00
parent 9dcb12131b
commit 0e35aced01
77 changed files with 725 additions and 735 deletions

View File

@@ -34,7 +34,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PublicMessag
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}
@@ -47,7 +47,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &PublicMessa
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: PublicMessage::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}
@@ -84,7 +84,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PrivateMessa
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}
@@ -97,7 +97,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &PrivateMess
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: PrivateMessage::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}

View File

@@ -25,7 +25,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for PlayerUpdate
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}
@@ -38,7 +38,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &PlayerUpdat
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: PlayerUpdated::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}

View File

@@ -34,7 +34,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for RoomJoined {
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: Self::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}
@@ -47,7 +47,7 @@ impl <C: Send + 'static> polariton_server::events::IntoEvent<C> for &RoomJoined
fn into_event(self) -> polariton::operation::Event<C> {
polariton::operation::Event {
code: RoomJoined::CODE,
params: self.as_event_params().into(),
params: self.as_event_params(),
}
}
}

View File

@@ -11,8 +11,8 @@ pub struct SimpleChatFunc<const CODE: u8, U: Send + Sync, F: (Fn(ParameterTable<
impl <C: Send + Sync + 'static, const CODE: u8, U: Send + Sync, F: (Fn(ParameterTable<C>, &U, &crate::state::ChatImpl) -> Result<ParameterTable<C>, i16>) + Send + Sync> SimpleChatFunc<CODE, U, F, C> {
pub fn new(f: F, chat: crate::state::ChatImpl) -> Self {
Self {
_user_ty: std::marker::PhantomData::default(),
_custom_ty: std::marker::PhantomData::default(),
_user_ty: std::marker::PhantomData,
_custom_ty: std::marker::PhantomData,
chat,
func: f,
}

View File

@@ -24,7 +24,7 @@ impl <C: Send + 'static> SimpleOperation<C> for PublicMessageSender {
if let Some(Typed::Str(channel_name)) = params.remove(&CHANNEL_NAME_PARAM_KEY) {
if let Some(Typed::Str(message_text)) = params.remove(&MESSAGE_TEXT_PARAM_KEY) {
let user = user.user()?;
if message_text.string.bytes().len() > MAX_MESSAGE_LEN {
if message_text.string.len() > MAX_MESSAGE_LEN {
log::warn!("Rejecting too long chat message from {}", user.public_id());
return Err((oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16).into())
}
@@ -65,7 +65,7 @@ impl <C: Send + 'static> SimpleOperation<C> for PrivateMessageSender {
if let Some(Typed::Str(username)) = params.remove(&USERNAME_PARAM_KEY) {
if let Some(Typed::Str(message_text)) = params.remove(&MESSAGE_TEXT_PARAM_KEY) {
let user = user.user()?;
if message_text.string.bytes().len() > MAX_MESSAGE_LEN {
if message_text.string.len() > MAX_MESSAGE_LEN {
log::warn!("Rejecting too long chat message from {}", user.public_id());
return Err((oj_rc_core::data::error_codes::ChatErrorCodes::Flood as i16).into())
}

View File

@@ -36,7 +36,7 @@ impl ChatSystemConfig {
return result;
}
}
return "Invalid command".to_owned()
"Invalid command".to_owned()
}
pub fn is_command_channel(&self, channel: &str) -> bool {
@@ -66,11 +66,7 @@ impl ChatCommand {
}
fn perform_if_match(&self, text: &str, ctx: CommandContext) -> Option<String> {
if let Some(cap) = self.regex.captures(text) {
Some(self.op.perform_command(cap, ctx))
} else {
None
}
self.regex.captures(text).map(|cap| self.op.perform_command(cap, ctx))
}
}
@@ -122,7 +118,7 @@ impl BuiltIn {
}
},
Self::TotalUsers => {
format!("User count is not supported")
"User count is not supported".to_string()
},
}
}

View File

@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod chat;
pub use chat::{ChatSystem, ChatProvider};