From b479d56c1060b21c6a0793db68101f4168bb8b33 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 14 Jan 2024 18:55:35 +0800 Subject: [PATCH] format apps/chat-test --- apps/chat-test/src/main.rs | 28 ++++++++-------------------- apps/chat-test/src/tests.rs | 6 +++--- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/apps/chat-test/src/main.rs b/apps/chat-test/src/main.rs index 797bbc83e..6fd982b56 100644 --- a/apps/chat-test/src/main.rs +++ b/apps/chat-test/src/main.rs @@ -11,12 +11,7 @@ use xous_ipc::Buffer; fn main() -> ! { let stack_size = 1024 * 1024; - std::thread::Builder::new() - .stack_size(stack_size) - .spawn(wrapped_main) - .unwrap() - .join() - .unwrap() + std::thread::Builder::new().stack_size(stack_size).spawn(wrapped_main).unwrap().join().unwrap() } fn wrapped_main() -> ! { @@ -26,11 +21,8 @@ fn wrapped_main() -> ! { const HEAP_LARGER_LIMIT: usize = 2048 * 1024; let new_limit = HEAP_LARGER_LIMIT; - let result = xous::rsyscall(xous::SysCall::AdjustProcessLimit( - xous::Limits::HeapMaximum as usize, - 0, - new_limit, - )); + let result = + xous::rsyscall(xous::SysCall::AdjustProcessLimit(xous::Limits::HeapMaximum as usize, 0, new_limit)); if let Ok(xous::Result::Scalar2(1, current_limit)) = result { xous::rsyscall(xous::SysCall::AdjustProcessLimit( @@ -45,9 +37,7 @@ fn wrapped_main() -> ! { } let xns = xous_names::XousNames::new().unwrap(); - let sid = xns - .register_name(SERVER_NAME_MTXCHAT, None) - .expect("can't register server"); + let sid = xns.register_name(SERVER_NAME_MTXCHAT, None).expect("can't register server"); log::trace!("registered with NS -- {:?}", sid); let chat = Chat::new( @@ -85,13 +75,11 @@ fn wrapped_main() -> ! { }); } Some(ChatTestOp::Post) => { - let buffer = - unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) }; - let s = buffer - .to_original::, _>() - .unwrap(); + let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) }; + let s = buffer.to_original::, _>().unwrap(); if s.len() > 0 { - // capture input instead of calling here, so message can drop and calling server is released + // capture input instead of calling here, so message can drop and calling server is + // released log::info!("got Post {:?}", s.to_string()); } } diff --git a/apps/chat-test/src/tests.rs b/apps/chat-test/src/tests.rs index 283688f07..266510efc 100644 --- a/apps/chat-test/src/tests.rs +++ b/apps/chat-test/src/tests.rs @@ -13,9 +13,9 @@ pub fn test_ui(chat: &Chat) { chat.post_add("alice", 1_700_000_000, "hello world!", None).ok(); chat.post_add("bob", 1_700_000_002, "hi alice!", None).ok(); for i in 0..5 { - chat.post_add("alice", 1_700_000_005 + i*4, &format!("alice sez {}", i), None).ok(); - chat.post_add("bob", 1_700_000_006 + i*4, &format!("bob sez {}", i), None).ok(); - chat.post_add("trent", 1_700_000_007 + i*4, &format!("trent sez {}", i), None).ok(); + chat.post_add("alice", 1_700_000_005 + i * 4, &format!("alice sez {}", i), None).ok(); + chat.post_add("bob", 1_700_000_006 + i * 4, &format!("bob sez {}", i), None).ok(); + chat.post_add("trent", 1_700_000_007 + i * 4, &format!("trent sez {}", i), None).ok(); } chat.post_add("alice", 1_700_001_000, "eom", None).ok();