优化代码结构和性能

This commit is contained in:
shenjack 2024-02-25 02:12:11 +08:00
parent 5381ef598a
commit 29f6b2efaf
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 1 additions and 2 deletions

View File

@ -18,7 +18,7 @@ pub enum At {
} }
impl At { impl At {
/// new_from_json(&message["at"]) #[inline]
pub fn new_from_json(json: &JsonValue) -> Self { pub fn new_from_json(json: &JsonValue) -> Self {
match json { match json {
JsonValue::Bool(b) => Self::Bool(*b), JsonValue::Bool(b) => Self::Bool(*b),

View File

@ -51,7 +51,6 @@ pub async fn add_message(payload: Payload, client: Client) {
pub async fn set_messages(payload: Payload, _client: Client) { pub async fn set_messages(payload: Payload, _client: Client) {
if let Payload::Text(values) = payload { if let Payload::Text(values) = payload {
if let Some(value) = values.first() { if let Some(value) = values.first() {
println!("{:#?}", value);
let messages: Vec<Message> = serde_json::from_value(value["messages"].clone()).unwrap(); let messages: Vec<Message> = serde_json::from_value(value["messages"].clone()).unwrap();
let room_id = value["roomId"].as_i64().unwrap(); let room_id = value["roomId"].as_i64().unwrap();
info!("set_messages {} len: {}", room_id.to_string().cyan(), messages.len()); info!("set_messages {} len: {}", room_id.to_string().cyan(), messages.len());